        <!DOCTYPE html>
        <html>
        <head>
                <meta charset="utf-8">
        <title>mat4 class / vector_math Library / Dart Documentation</title>
        <link rel="stylesheet" type="text/css"
            href="../styles.css">
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800" rel="stylesheet" type="text/css">
        <link rel="shortcut icon" href="../favicon.ico">
        
        </head>
        <body data-library="vector_math" data-type="mat4">
        <div class="page">
        <div class="header">
          <a href="../index.html"><div class="logo"></div></a>
          <a href="../index.html">Dart Documentation</a>
         &rsaquo; <a href="../vector_math.html">vector_math</a> &rsaquo; <a href="../vector_math/mat4.html">mat4</a>        <div id="search-box">
          <input type="search" name="q" id="q" autocomplete="off"
              class="search-input" placeholder="Search API">
        </div>
        
      </div>
      <div class="drop-down" id="drop-down"></div>
      
        <div class="nav">
        
</div>
<div class="content">
        <h2><strong>mat4</strong>
          class
        </h2>
        
<button id="show-inherited" class="show-inherited">Hide inherited</button>
<div class="doc">
<p>mat4 is a column major matrix where each column is represented by <a class="crossref" href="../vector_math/vec4.html">vec4</a>. This matrix has 4 columns and 4 rows.</p>
<pre class="source">
class mat4 {
 vec4 col0;
 vec4 col1;
 vec4 col2;
 vec4 col3;
 /// Constructs a new mat4. Supports GLSL like syntax so many possible inputs. Defaults to identity matrix.
 mat4([dynamic arg0, dynamic arg1, dynamic arg2, dynamic arg3, dynamic arg4, dynamic arg5, dynamic arg6, dynamic arg7, dynamic arg8, dynamic arg9, dynamic arg10, dynamic arg11, dynamic arg12, dynamic arg13, dynamic arg14, dynamic arg15]) {
   //Initialize the matrix as the identity matrix
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = 1.0;
   col1.y = 1.0;
   col2.z = 1.0;
   col3.w = 1.0;
   if (arg0 is num &amp;&amp; arg1 is num &amp;&amp; arg2 is num &amp;&amp; arg3 is num &amp;&amp; arg4 is num &amp;&amp; arg5 is num &amp;&amp; arg6 is num &amp;&amp; arg7 is num &amp;&amp; arg8 is num &amp;&amp; arg9 is num &amp;&amp; arg10 is num &amp;&amp; arg11 is num &amp;&amp; arg12 is num &amp;&amp; arg13 is num &amp;&amp; arg14 is num &amp;&amp; arg15 is num) {
     col0.x = arg0;
     col0.y = arg1;
     col0.z = arg2;
     col0.w = arg3;
     col1.x = arg4;
     col1.y = arg5;
     col1.z = arg6;
     col1.w = arg7;
     col2.x = arg8;
     col2.y = arg9;
     col2.z = arg10;
     col2.w = arg11;
     col3.x = arg12;
     col3.y = arg13;
     col3.z = arg14;
     col3.w = arg15;
     return;
   }
   if (arg0 is num &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
     col0.x = arg0;
     col1.y = arg0;
     col2.z = arg0;
     col3.w = arg0;
     return;
   }
   if (arg0 is vec4 &amp;&amp; arg1 is vec4 &amp;&amp; arg2 is vec4 &amp;&amp; arg3 is vec4) {
     col0 = arg0;
     col1 = arg1;
     col2 = arg2;
     col3 = arg3;
     return;
   }
   if (arg0 is mat4) {
     col0 = arg0.col0;
     col1 = arg0.col1;
     col2 = arg0.col2;
     col3 = arg0.col3;
     return;
   }
   if (arg0 is mat3) {
     col0.x = arg0.col0.x;
     col0.y = arg0.col0.y;
     col0.z = arg0.col0.z;
     col1.x = arg0.col1.x;
     col1.y = arg0.col1.y;
     col1.z = arg0.col1.z;
     col2.x = arg0.col2.x;
     col2.y = arg0.col2.y;
     col2.z = arg0.col2.z;
     return;
   }
   if (arg0 is mat2) {
     col0.x = arg0.col0.x;
     col0.y = arg0.col0.y;
     col1.x = arg0.col1.x;
     col1.y = arg0.col1.y;
     return;
   }
   if (arg0 is vec2 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
     col0.x = arg0.x;
     col1.y = arg0.y;
   }
   if (arg0 is vec3 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
     col0.x = arg0.x;
     col1.y = arg0.y;
     col2.z = arg0.z;
   }
   if (arg0 is vec4 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
     col0.x = arg0.x;
     col1.y = arg0.y;
     col2.z = arg0.z;
     col3.w = arg0.w;
   }
 }
 /// Constructs a new [mat4] from computing the outer product of [u] and [v].
 mat4.outer(vec4 u, vec4 v) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = u.x * v.x;
   col0.y = u.x * v.y;
   col0.z = u.x * v.z;
   col0.w = u.x * v.w;
   col1.x = u.y * v.x;
   col1.y = u.y * v.y;
   col1.z = u.y * v.z;
   col1.w = u.y * v.w;
   col2.x = u.z * v.x;
   col2.y = u.z * v.y;
   col2.z = u.z * v.z;
   col2.w = u.z * v.w;
   col3.x = u.w * v.x;
   col3.y = u.w * v.y;
   col3.z = u.w * v.z;
   col3.w = u.w * v.w;
 }
 /// Constructs a new [mat4] filled with zeros.
 mat4.zero() {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = 0.0;
   col0.y = 0.0;
   col0.z = 0.0;
   col0.w = 0.0;
   col1.x = 0.0;
   col1.y = 0.0;
   col1.z = 0.0;
   col1.w = 0.0;
   col2.x = 0.0;
   col2.y = 0.0;
   col2.z = 0.0;
   col2.w = 0.0;
   col3.x = 0.0;
   col3.y = 0.0;
   col3.z = 0.0;
   col3.w = 0.0;
 }
 /// Constructs a new identity [mat4].
 mat4.identity() {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = 1.0;
   col1.y = 1.0;
   col2.z = 1.0;
   col3.w = 1.0;
 }
 /// Constructs a new [mat4] which is a copy of [other].
 mat4.copy(mat4 other) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = other.col0.x;
   col0.y = other.col0.y;
   col0.z = other.col0.z;
   col0.w = other.col0.w;
   col1.x = other.col1.x;
   col1.y = other.col1.y;
   col1.z = other.col1.z;
   col1.w = other.col1.w;
   col2.x = other.col2.x;
   col2.y = other.col2.y;
   col2.z = other.col2.z;
   col2.w = other.col2.w;
   col3.x = other.col3.x;
   col3.y = other.col3.y;
   col3.z = other.col3.z;
   col3.w = other.col3.w;
 }
 //// Constructs a new [mat4] representation a rotation of [radians] around the X axis
 mat4.rotationX(num radians_) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col3.w = 1.0;
   setRotationX(radians_);
 }
 //// Constructs a new [mat4] representation a rotation of [radians] around the Y axis
 mat4.rotationY(num radians_) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col3.w = 1.0;
   setRotationY(radians_);
 }
 //// Constructs a new [mat4] representation a rotation of [radians] around the Z axis
 mat4.rotationZ(num radians_) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col3.w = 1.0;
   setRotationZ(radians_);
 }
 /// Constructs a new [mat4] translation matrix from [translation]
 mat4.translation(vec3 translation) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = 1.0;
   col1.y = 1.0;
   col2.z = 1.0;
   col3.w = 1.0;
   col3.xyz = translation;
 }
 /// Constructs a new [mat4] translation from [x], [y], and [z]
 mat4.translationRaw(num x, num y, num z) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = 1.0;
   col1.y = 1.0;
   col2.z = 1.0;
   col3.w = 1.0;
   col3.x = x;
   col3.y = y;
   col3.z = z;
 }
 //// Constructs a new [mat4] scale of [x], [y], and [z]
 mat4.scaleVec(vec3 scale_) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = scale_.x;
   col1.y = scale_.y;
   col2.z = scale_.z;
   col3.w = 1.0;
 }
 //// Constructs a new [mat4] representening a scale of [x], [y], and [z]
 mat4.scaleRaw(num x, num y, num z) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = x;
   col1.y = y;
   col2.z = z;
   col3.w = 1.0;
 }
 mat4.raw(num arg0, num arg1, num arg2, num arg3, num arg4, num arg5, num arg6, num arg7, num arg8, num arg9, num arg10, num arg11, num arg12, num arg13, num arg14, num arg15) {
   col0 = new vec4.zero();
   col1 = new vec4.zero();
   col2 = new vec4.zero();
   col3 = new vec4.zero();
   col0.x = arg0;
   col0.y = arg1;
   col0.z = arg2;
   col0.w = arg3;
   col1.x = arg4;
   col1.y = arg5;
   col1.z = arg6;
   col1.w = arg7;
   col2.x = arg8;
   col2.y = arg9;
   col2.z = arg10;
   col2.w = arg11;
   col3.x = arg12;
   col3.y = arg13;
   col3.z = arg14;
   col3.w = arg15;
 }
 /// Returns a printable string
 String toString() {
   String s = '';
   s = '$s[0] ${getRow(0)}\n';
   s = '$s[1] ${getRow(1)}\n';
   s = '$s[2] ${getRow(2)}\n';
   s = '$s[3] ${getRow(3)}\n';
   return s;
 }
 /// Returns the number of rows in the matrix.
 int get rows =&gt; 4;
 /// Returns the number of columns in the matrix.
 int get cols =&gt; 4;
 /// Returns the number of columns in the matrix.
 int get length =&gt; 4;
 /// Gets the [column] of the matrix
 vec4 operator[](int column) {
   assert(column &gt;= 0 &amp;&amp; column &lt; 4);
   switch (column) {
     case 0: return col0;
     case 1: return col1;
     case 2: return col2;
     case 3: return col3;
   }
   throw new ArgumentError(column);
 }
 /// Assigns the [column] of the matrix [arg]
 void operator[]=(int column, vec4 arg) {
   assert(column &gt;= 0 &amp;&amp; column &lt; 4);
   switch (column) {
     case 0: col0 = arg; break;
     case 1: col1 = arg; break;
     case 2: col2 = arg; break;
     case 3: col3 = arg; break;
   }
   throw new ArgumentError(column);
 }
 /// Returns row 0
 vec4 get row0 =&gt; getRow(0);
 /// Returns row 1
 vec4 get row1 =&gt; getRow(1);
 /// Returns row 2
 vec4 get row2 =&gt; getRow(2);
 /// Returns row 3
 vec4 get row3 =&gt; getRow(3);
 /// Sets row 0 to [arg]
 set row0(vec4 arg) =&gt; setRow(0, arg);
 /// Sets row 1 to [arg]
 set row1(vec4 arg) =&gt; setRow(1, arg);
 /// Sets row 2 to [arg]
 set row2(vec4 arg) =&gt; setRow(2, arg);
 /// Sets row 3 to [arg]
 set row3(vec4 arg) =&gt; setRow(3, arg);
 /// Assigns the [column] of the matrix [arg]
 void setRow(int row, vec4 arg) {
   assert(row &gt;= 0 &amp;&amp; row &lt; 4);
   col0[row] = arg.x;
   col1[row] = arg.y;
   col2[row] = arg.z;
   col3[row] = arg.w;
 }
 /// Gets the [row] of the matrix
 vec4 getRow(int row) {
   assert(row &gt;= 0 &amp;&amp; row &lt; 4);
   vec4 r = new vec4.zero();
   r.x = col0[row];
   r.y = col1[row];
   r.z = col2[row];
   r.w = col3[row];
   return r;
 }
 /// Assigns the [column] of the matrix [arg]
 void setColumn(int column, vec4 arg) {
   assert(column &gt;= 0 &amp;&amp; column &lt; 4);
   this[column] = arg;
 }
 /// Gets the [column] of the matrix
 vec4 getColumn(int column) {
   assert(column &gt;= 0 &amp;&amp; column &lt; 4);
   return new vec4.copy(this[column]);
 }
 /// Returns a new vector or matrix by multiplying [this] with [arg].
 dynamic operator*(dynamic arg) {
   if (arg is num) {
     mat4 r = new mat4.zero();
     r.col0.x = col0.x * arg;
     r.col0.y = col0.y * arg;
     r.col0.z = col0.z * arg;
     r.col0.w = col0.w * arg;
     r.col1.x = col1.x * arg;
     r.col1.y = col1.y * arg;
     r.col1.z = col1.z * arg;
     r.col1.w = col1.w * arg;
     r.col2.x = col2.x * arg;
     r.col2.y = col2.y * arg;
     r.col2.z = col2.z * arg;
     r.col2.w = col2.w * arg;
     r.col3.x = col3.x * arg;
     r.col3.y = col3.y * arg;
     r.col3.z = col3.z * arg;
     r.col3.w = col3.w * arg;
     return r;
   }
   if (arg is vec4) {
     vec4 r = new vec4.zero();
     r.x =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + (this.col3.x * arg.w);
     r.y =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + (this.col3.y * arg.w);
     r.z =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + (this.col3.z * arg.w);
     r.w =  (this.col0.w * arg.x) + (this.col1.w * arg.y) + (this.col2.w * arg.z) + (this.col3.w * arg.w);
     return r;
   }
   if (arg is vec3) {
     vec3 r = new vec3.zero();
     r.x =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + col3.x;
     r.y =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + col3.y;
     r.z =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + col3.z;
     return r;
   }
   if (4 == arg.rows) {
     dynamic r = null;
     if (arg.cols == 4) {
       r = new mat4.zero();
       r.col0.x =  (this.col0.x * arg.col0.x) + (this.col1.x * arg.col0.y) + (this.col2.x * arg.col0.z) + (this.col3.x * arg.col0.w);
       r.col1.x =  (this.col0.x * arg.col1.x) + (this.col1.x * arg.col1.y) + (this.col2.x * arg.col1.z) + (this.col3.x * arg.col1.w);
       r.col2.x =  (this.col0.x * arg.col2.x) + (this.col1.x * arg.col2.y) + (this.col2.x * arg.col2.z) + (this.col3.x * arg.col2.w);
       r.col3.x =  (this.col0.x * arg.col3.x) + (this.col1.x * arg.col3.y) + (this.col2.x * arg.col3.z) + (this.col3.x * arg.col3.w);
       r.col0.y =  (this.col0.y * arg.col0.x) + (this.col1.y * arg.col0.y) + (this.col2.y * arg.col0.z) + (this.col3.y * arg.col0.w);
       r.col1.y =  (this.col0.y * arg.col1.x) + (this.col1.y * arg.col1.y) + (this.col2.y * arg.col1.z) + (this.col3.y * arg.col1.w);
       r.col2.y =  (this.col0.y * arg.col2.x) + (this.col1.y * arg.col2.y) + (this.col2.y * arg.col2.z) + (this.col3.y * arg.col2.w);
       r.col3.y =  (this.col0.y * arg.col3.x) + (this.col1.y * arg.col3.y) + (this.col2.y * arg.col3.z) + (this.col3.y * arg.col3.w);
       r.col0.z =  (this.col0.z * arg.col0.x) + (this.col1.z * arg.col0.y) + (this.col2.z * arg.col0.z) + (this.col3.z * arg.col0.w);
       r.col1.z =  (this.col0.z * arg.col1.x) + (this.col1.z * arg.col1.y) + (this.col2.z * arg.col1.z) + (this.col3.z * arg.col1.w);
       r.col2.z =  (this.col0.z * arg.col2.x) + (this.col1.z * arg.col2.y) + (this.col2.z * arg.col2.z) + (this.col3.z * arg.col2.w);
       r.col3.z =  (this.col0.z * arg.col3.x) + (this.col1.z * arg.col3.y) + (this.col2.z * arg.col3.z) + (this.col3.z * arg.col3.w);
       r.col0.w =  (this.col0.w * arg.col0.x) + (this.col1.w * arg.col0.y) + (this.col2.w * arg.col0.z) + (this.col3.w * arg.col0.w);
       r.col1.w =  (this.col0.w * arg.col1.x) + (this.col1.w * arg.col1.y) + (this.col2.w * arg.col1.z) + (this.col3.w * arg.col1.w);
       r.col2.w =  (this.col0.w * arg.col2.x) + (this.col1.w * arg.col2.y) + (this.col2.w * arg.col2.z) + (this.col3.w * arg.col2.w);
       r.col3.w =  (this.col0.w * arg.col3.x) + (this.col1.w * arg.col3.y) + (this.col2.w * arg.col3.z) + (this.col3.w * arg.col3.w);
       return r;
     }
     return r;
   }
   throw new ArgumentError(arg);
 }
 /// Returns new matrix after component wise [this] + [arg]
 mat4 operator+(mat4 arg) {
   mat4 r = new mat4.zero();
   r.col0.x = col0.x + arg.col0.x;
   r.col0.y = col0.y + arg.col0.y;
   r.col0.z = col0.z + arg.col0.z;
   r.col0.w = col0.w + arg.col0.w;
   r.col1.x = col1.x + arg.col1.x;
   r.col1.y = col1.y + arg.col1.y;
   r.col1.z = col1.z + arg.col1.z;
   r.col1.w = col1.w + arg.col1.w;
   r.col2.x = col2.x + arg.col2.x;
   r.col2.y = col2.y + arg.col2.y;
   r.col2.z = col2.z + arg.col2.z;
   r.col2.w = col2.w + arg.col2.w;
   r.col3.x = col3.x + arg.col3.x;
   r.col3.y = col3.y + arg.col3.y;
   r.col3.z = col3.z + arg.col3.z;
   r.col3.w = col3.w + arg.col3.w;
   return r;
 }
 /// Returns new matrix after component wise [this] - [arg]
 mat4 operator-(mat4 arg) {
   mat4 r = new mat4.zero();
   r.col0.x = col0.x - arg.col0.x;
   r.col0.y = col0.y - arg.col0.y;
   r.col0.z = col0.z - arg.col0.z;
   r.col0.w = col0.w - arg.col0.w;
   r.col1.x = col1.x - arg.col1.x;
   r.col1.y = col1.y - arg.col1.y;
   r.col1.z = col1.z - arg.col1.z;
   r.col1.w = col1.w - arg.col1.w;
   r.col2.x = col2.x - arg.col2.x;
   r.col2.y = col2.y - arg.col2.y;
   r.col2.z = col2.z - arg.col2.z;
   r.col2.w = col2.w - arg.col2.w;
   r.col3.x = col3.x - arg.col3.x;
   r.col3.y = col3.y - arg.col3.y;
   r.col3.z = col3.z - arg.col3.z;
   r.col3.w = col3.w - arg.col3.w;
   return r;
 }
 /// Translate this matrix by a [vec3], [vec4], or x,y,z
 mat4 translate(dynamic x, [num y = 0.0, num z = 0.0]) {
   double tx;
   double ty;
   double tz;
   double tw = x is vec4 ? x.w : 1.0;
   if (x is vec3 || x is vec4) {
     tx = x.x;
     ty = x.y;
     tz = x.z;
   } else {
     tx = x;
     ty = y;
     tz = z;
   }
   var t1 = col0.x * tx + col1.x * ty + col2.x * tz + col3.x * tw;
   var t2 = col0.y * tx + col1.y * ty + col2.y * tz + col3.y * tw;
   var t3 = col0.z * tx + col1.z * ty + col2.z * tz + col3.z * tw;
   var t4 = col0.w * tx + col1.w * ty + col2.w * tz + col3.w * tw;
   col3.x = t1;
   col3.y = t2;
   col3.z = t3;
   col3.w = t4;
   return this;
 }
 /// Rotate this [angle] radians around [axis]
 mat4 rotate(vec3 axis, num angle_) {
   var len = axis.length;
   double angle = angle_.toDouble();
   var x = axis.x/len;
   var y = axis.y/len;
   var z = axis.z/len;
   var c = cos(angle);
   var s = sin(angle);
   var C = 1.0 - c;
   var m11 = x * x * C + c;
   var m12 = x * y * C - z * s;
   var m13 = x * z * C + y * s;
   var m21 = y * x * C + z * s;
   var m22 = y * y * C + c;
   var m23 = y * z * C - x * s;
   var m31 = z * x * C - y * s;
   var m32 = z * y * C + x * s;
   var m33 = z * z * C + c;
   var t1 = col0.x * m11 + col1.x * m21 + col2.x * m31 + col3.x * 0.0;
   var t2 = col0.y * m11 + col1.y * m21 + col2.y * m31 + col3.y * 0.0;
   var t3 = col0.z * m11 + col1.z * m21 + col2.z * m31 + col3.z * 0.0;
   var t4 = col0.w * m11 + col1.w * m21 + col2.w * m31 + col3.w * 0.0;
   var t5 = col0.x * m12 + col1.x * m22 + col2.x * m32 + col3.x * 0.0;
   var t6 = col0.y * m12 + col1.y * m22 + col2.y * m32 + col3.y * 0.0;
   var t7 = col0.z * m12 + col1.z * m22 + col2.z * m32 + col3.z * 0.0;
   var t8 = col0.w * m12 + col1.w * m22 + col2.w * m32 + col3.w * 0.0;
   var t9 = col0.x * m13 + col1.x * m23 + col2.x * m33 + col3.x * 0.0;
   var t10 = col0.y * m13 + col1.y * m23 + col2.y * m33 + col3.y * 0.0;
   var t11 = col0.z * m13 + col1.z * m23 + col2.z * m33 + col3.z * 0.0;
   var t12 = col0.w * m13 + col1.w * m23 + col2.w * m33 + col3.w * 0.0;
   col0.x = t1;
   col0.y = t2;
   col0.z = t3;
   col0.w = t4;
   col1.x = t5;
   col1.y = t6;
   col1.z = t7;
   col1.w = t8;
   col2.x = t9;
   col2.y = t10;
   col2.z = t11;
   col2.w = t12;
   return this;
 }
 /// Rotate this [angle] radians around X
 mat4 rotateX(num angle_) {
   double angle = angle_.toDouble();
   double cosAngle = cos(angle);
   double sinAngle = sin(angle);
   var t1 = col0.x * 0.0 + col1.x * cosAngle + col2.x * sinAngle + col3.x * 0.0;
   var t2 = col0.y * 0.0 + col1.y * cosAngle + col2.y * sinAngle + col3.y * 0.0;
   var t3 = col0.z * 0.0 + col1.z * cosAngle + col2.z * sinAngle + col3.z * 0.0;
   var t4 = col0.w * 0.0 + col1.w * cosAngle + col2.w * sinAngle + col3.w * 0.0;
   var t5 = col0.x * 0.0 + col1.x * -sinAngle + col2.x * cosAngle + col3.x * 0.0;
   var t6 = col0.y * 0.0 + col1.y * -sinAngle + col2.y * cosAngle + col3.y * 0.0;
   var t7 = col0.z * 0.0 + col1.z * -sinAngle + col2.z * cosAngle + col3.z * 0.0;
   var t8 = col0.w * 0.0 + col1.w * -sinAngle + col2.w * cosAngle + col3.w * 0.0;
   col1.x = t1;
   col1.y = t2;
   col1.z = t3;
   col1.w = t4;
   col2.x = t5;
   col2.y = t6;
   col2.z = t7;
   col2.w = t8;
   return this;
 }
 /// Rotate this matrix [angle] radians around Y
 mat4 rotateY(double angle) {
   double cosAngle = cos(angle);
   double sinAngle = sin(angle);
   var t1 = col0.x * cosAngle + col1.x * 0.0 + col2.x * sinAngle + col3.x * 0.0;
   var t2 = col0.y * cosAngle + col1.y * 0.0 + col2.y * sinAngle + col3.y * 0.0;
   var t3 = col0.z * cosAngle + col1.z * 0.0 + col2.z * sinAngle + col3.z * 0.0;
   var t4 = col0.w * cosAngle + col1.w * 0.0 + col2.w * sinAngle + col3.w * 0.0;
   var t5 = col0.x * -sinAngle + col1.x * 0.0 + col2.x * cosAngle + col3.x * 0.0;
   var t6 = col0.y * -sinAngle + col1.y * 0.0 + col2.y * cosAngle + col3.y * 0.0;
   var t7 = col0.z * -sinAngle + col1.z * 0.0 + col2.z * cosAngle + col3.z * 0.0;
   var t8 = col0.w * -sinAngle + col1.w * 0.0 + col2.w * cosAngle + col3.w * 0.0;
   col0.x = t1;
   col0.y = t2;
   col0.z = t3;
   col0.w = t4;
   col2.x = t5;
   col2.y = t6;
   col2.z = t7;
   col2.w = t8;
   return this;
 }
 /// Rotate this matrix [angle] radians around Z
 mat4 rotateZ(double angle) {
   double cosAngle = cos(angle);
   double sinAngle = sin(angle);
   var t1 = col0.x * cosAngle + col1.x * sinAngle + col2.x * 0.0 + col3.x * 0.0;
   var t2 = col0.y * cosAngle + col1.y * sinAngle + col2.y * 0.0 + col3.y * 0.0;
   var t3 = col0.z * cosAngle + col1.z * sinAngle + col2.z * 0.0 + col3.z * 0.0;
   var t4 = col0.w * cosAngle + col1.w * sinAngle + col2.w * 0.0 + col3.w * 0.0;
   var t5 = col0.x * -sinAngle + col1.x * cosAngle + col2.x * 0.0 + col3.x * 0.0;
   var t6 = col0.y * -sinAngle + col1.y * cosAngle + col2.y * 0.0 + col3.y * 0.0;
   var t7 = col0.z * -sinAngle + col1.z * cosAngle + col2.z * 0.0 + col3.z * 0.0;
   var t8 = col0.w * -sinAngle + col1.w * cosAngle + col2.w * 0.0 + col3.w * 0.0;
   col0.x = t1;
   col0.y = t2;
   col0.z = t3;
   col0.w = t4;
   col1.x = t5;
   col1.y = t6;
   col1.z = t7;
   col1.w = t8;
   return this;
 }
 /// Scale this matrix by a [vec3], [vec4], or x,y,z
 mat4 scale(dynamic x, [num y = null, num z = null]) {
   double sx;
   double sy;
   double sz;
   double sw = x is vec4 ? x.w : 1.0;
   if (x is vec3 || x is vec4) {
     sx = x.x;
     sy = x.y;
     sz = x.z;
   } else {
     sx = x;
     sy = y == null ? x : y.toDouble();
     sz = z == null ? x : z.toDouble();
   }
   col0.x *= sx;
   col1.x *= sx;
   col2.x *= sx;
   col3.x *= sx;
   col0.y *= sy;
   col1.y *= sy;
   col2.y *= sy;
   col3.y *= sy;
   col0.z *= sz;
   col1.z *= sz;
   col2.z *= sz;
   col3.z *= sz;
   col0.w *= sw;
   col1.w *= sw;
   col2.w *= sw;
   col3.w *= sw;
   return this;
 }
 /// Returns new matrix -this
 mat4 operator-() {
   mat4 r = new mat4.zero();
   r[0] = -this[0];
   r[1] = -this[1];
   r[2] = -this[2];
   r[3] = -this[3];
   return r;
 }
 /// Zeros [this].
 mat4 setZero() {
   col0.x = 0.0;
   col0.y = 0.0;
   col0.z = 0.0;
   col0.w = 0.0;
   col1.x = 0.0;
   col1.y = 0.0;
   col1.z = 0.0;
   col1.w = 0.0;
   col2.x = 0.0;
   col2.y = 0.0;
   col2.z = 0.0;
   col2.w = 0.0;
   col3.x = 0.0;
   col3.y = 0.0;
   col3.z = 0.0;
   col3.w = 0.0;
   return this;
 }
 /// Makes [this] into the identity matrix.
 mat4 setIdentity() {
   col0.x = 1.0;
   col0.y = 0.0;
   col0.z = 0.0;
   col0.w = 0.0;
   col1.x = 0.0;
   col1.y = 1.0;
   col1.z = 0.0;
   col1.w = 0.0;
   col2.x = 0.0;
   col2.y = 0.0;
   col2.z = 1.0;
   col2.w = 0.0;
   col3.x = 0.0;
   col3.y = 0.0;
   col3.z = 0.0;
   col3.w = 1.0;
   return this;
 }
 /// Returns the tranpose of this.
 mat4 transposed() {
   mat4 r = new mat4.zero();
   r.col0.x = col0.x;
   r.col0.y = col1.x;
   r.col0.z = col2.x;
   r.col0.w = col3.x;
   r.col1.x = col0.y;
   r.col1.y = col1.y;
   r.col1.z = col2.y;
   r.col1.w = col3.y;
   r.col2.x = col0.z;
   r.col2.y = col1.z;
   r.col2.z = col2.z;
   r.col2.w = col3.z;
   r.col3.x = col0.w;
   r.col3.y = col1.w;
   r.col3.z = col2.w;
   r.col3.w = col3.w;
   return r;
 }
 mat4 transpose() {
   double temp;
   temp = col1.x;
   col1.x = col0.y;
   col0.y = temp;
   temp = col2.x;
   col2.x = col0.z;
   col0.z = temp;
   temp = col3.x;
   col3.x = col0.w;
   col0.w = temp;
   temp = col2.y;
   col2.y = col1.z;
   col1.z = temp;
   temp = col3.y;
   col3.y = col1.w;
   col1.w = temp;
   temp = col3.z;
   col3.z = col2.w;
   col2.w = temp;
   return this;
 }
 /// Returns the component wise absolute value of this.
 mat4 absolute() {
   mat4 r = new mat4.zero();
   r.col0.x = col0.x.abs();
   r.col0.y = col0.y.abs();
   r.col0.z = col0.z.abs();
   r.col0.w = col0.w.abs();
   r.col1.x = col1.x.abs();
   r.col1.y = col1.y.abs();
   r.col1.z = col1.z.abs();
   r.col1.w = col1.w.abs();
   r.col2.x = col2.x.abs();
   r.col2.y = col2.y.abs();
   r.col2.z = col2.z.abs();
   r.col2.w = col2.w.abs();
   r.col3.x = col3.x.abs();
   r.col3.y = col3.y.abs();
   r.col3.z = col3.z.abs();
   r.col3.w = col3.w.abs();
   return r;
 }
 /// Returns the determinant of this matrix.
 double determinant() {
   double det2_01_01 = col0.x * col1.y - col0.y * col1.x;
   double det2_01_02 = col0.x * col1.z - col0.z * col1.x;
   double det2_01_03 = col0.x * col1.w - col0.w * col1.x;
   double det2_01_12 = col0.y * col1.z - col0.z * col1.y;
   double det2_01_13 = col0.y * col1.w - col0.w * col1.y;
   double det2_01_23 = col0.z * col1.w - col0.w * col1.z;
   double det3_201_012 = col2.x * det2_01_12 - col2.y * det2_01_02 + col2.z * det2_01_01;
   double det3_201_013 = col2.x * det2_01_13 - col2.y * det2_01_03 + col2.w * det2_01_01;
   double det3_201_023 = col2.x * det2_01_23 - col2.z * det2_01_03 + col2.w * det2_01_02;
   double det3_201_123 = col2.y * det2_01_23 - col2.z * det2_01_13 + col2.w * det2_01_12;
   return ( - det3_201_123 * col3.x + det3_201_023 * col3.y - det3_201_013 * col3.z + det3_201_012 * col3.w);
 }
 /// Returns the trace of the matrix. The trace of a matrix is the sum of the diagonal entries
 double trace() {
   double t = 0.0;
   t += col0.x;
   t += col1.y;
   t += col2.z;
   t += col3.w;
   return t;
 }
 /// Returns infinity norm of the matrix. Used for numerical analysis.
 double infinityNorm() {
   double norm = 0.0;
   {
     double row_norm = 0.0;
     row_norm += this[0][0].abs();
     row_norm += this[0][1].abs();
     row_norm += this[0][2].abs();
     row_norm += this[0][3].abs();
     norm = row_norm &gt; norm ? row_norm : norm;
   }
   {
     double row_norm = 0.0;
     row_norm += this[1][0].abs();
     row_norm += this[1][1].abs();
     row_norm += this[1][2].abs();
     row_norm += this[1][3].abs();
     norm = row_norm &gt; norm ? row_norm : norm;
   }
   {
     double row_norm = 0.0;
     row_norm += this[2][0].abs();
     row_norm += this[2][1].abs();
     row_norm += this[2][2].abs();
     row_norm += this[2][3].abs();
     norm = row_norm &gt; norm ? row_norm : norm;
   }
   {
     double row_norm = 0.0;
     row_norm += this[3][0].abs();
     row_norm += this[3][1].abs();
     row_norm += this[3][2].abs();
     row_norm += this[3][3].abs();
     norm = row_norm &gt; norm ? row_norm : norm;
   }
   return norm;
 }
 /// Returns relative error between [this] and [correct]
 double relativeError(mat4 correct) {
   mat4 diff = correct - this;
   double correct_norm = correct.infinityNorm();
   double diff_norm = diff.infinityNorm();
   return diff_norm/correct_norm;
 }
 /// Returns absolute error between [this] and [correct]
 double absoluteError(mat4 correct) {
   double this_norm = infinityNorm();
   double correct_norm = correct.infinityNorm();
   double diff_norm = (this_norm - correct_norm).abs();
   return diff_norm;
 }
 /// Returns the translation vector from this homogeneous transformation matrix.
 vec3 getTranslation() {
   return new vec3.raw(col3.x, col3.y, col3.z);
 }
 /// Sets the translation vector in this homogeneous transformation matrix.
 void setTranslation(vec3 T) {
   col3.xyz = T;
 }
 /// Returns the rotation matrix from this homogeneous transformation matrix.
 mat3 getRotation() {
   mat3 r = new mat3.zero();
   r.col0 = new vec3.raw(this.col0.x,this.col0.y,this.col0.z);
   r.col1 = new vec3.raw(this.col1.x,this.col1.y,this.col1.z);
   r.col2 = new vec3.raw(this.col2.x,this.col2.y,this.col2.z);
   return r;
 }
 /// Sets the rotation matrix in this homogeneous transformation matrix.
 void setRotation(mat3 rotation) {
   this.col0.xyz = rotation.col0;
   this.col1.xyz = rotation.col1;
   this.col2.xyz = rotation.col2;
 }
 /// Transposes just the upper 3x3 rotation matrix.
 mat4 transposeRotation() {
   double temp;
   temp = this.col0.y;
   this.col0.y = this.col1.x;
   this.col1.x = temp;
   temp = this.col0.z;
   this.col0.z = this.col2.x;
   this.col2.x = temp;
   temp = this.col1.x;
   this.col1.x = this.col0.y;
   this.col0.y = temp;
   temp = this.col1.z;
   this.col1.z = this.col2.y;
   this.col2.y = temp;
   temp = this.col2.x;
   this.col2.x = this.col0.z;
   this.col0.z = temp;
   temp = this.col2.y;
   this.col2.y = this.col1.z;
   this.col1.z = temp;
   return this;
 }
 double invert() {
   double a00 = col0.x;
   double a01 = col0.y;
   double a02 = col0.z;
   double a03 = col0.w;
   double a10 = col1.x;
   double a11 = col1.y;
   double a12 = col1.z;
   double a13 = col1.w;
   double a20 = col2.x;
   double a21 = col2.y;
   double a22 = col2.z;
   double a23 = col2.w;
   double a30 = col3.x;
   double a31 = col3.y;
   double a32 = col3.z;
   double a33 = col3.w;
   var b00 = a00 * a11 - a01 * a10;
   var b01 = a00 * a12 - a02 * a10;
   var b02 = a00 * a13 - a03 * a10;
   var b03 = a01 * a12 - a02 * a11;
   var b04 = a01 * a13 - a03 * a11;
   var b05 = a02 * a13 - a03 * a12;
   var b06 = a20 * a31 - a21 * a30;
   var b07 = a20 * a32 - a22 * a30;
   var b08 = a20 * a33 - a23 * a30;
   var b09 = a21 * a32 - a22 * a31;
   var b10 = a21 * a33 - a23 * a31;
   var b11 = a22 * a33 - a23 * a32;
   var det = (b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06);
   if (det == 0.0) { return det; }
   var invDet = 1.0 / det;
   col0.x = (a11 * b11 - a12 * b10 + a13 * b09) * invDet;
   col0.y = (-a01 * b11 + a02 * b10 - a03 * b09) * invDet;
   col0.z = (a31 * b05 - a32 * b04 + a33 * b03) * invDet;
   col0.w = (-a21 * b05 + a22 * b04 - a23 * b03) * invDet;
   col1.x = (-a10 * b11 + a12 * b08 - a13 * b07) * invDet;
   col1.y = (a00 * b11 - a02 * b08 + a03 * b07) * invDet;
   col1.z = (-a30 * b05 + a32 * b02 - a33 * b01) * invDet;
   col1.w = (a20 * b05 - a22 * b02 + a23 * b01) * invDet;
   col2.x = (a10 * b10 - a11 * b08 + a13 * b06) * invDet;
   col2.y = (-a00 * b10 + a01 * b08 - a03 * b06) * invDet;
   col2.z = (a30 * b04 - a31 * b02 + a33 * b00) * invDet;
   col2.w = (-a20 * b04 + a21 * b02 - a23 * b00) * invDet;
   col3.x = (-a10 * b09 + a11 * b07 - a12 * b06) * invDet;
   col3.y = (a00 * b09 - a01 * b07 + a02 * b06) * invDet;
   col3.z = (-a30 * b03 + a31 * b01 - a32 * b00) * invDet;
   col3.w = (a20 * b03 - a21 * b01 + a22 * b00) * invDet;
   return det;
 }
 double invertRotation() {
   double det = determinant();
   if (det == 0.0) {
     return 0.0;
   }
   double invDet = 1.0 / det;
   vec4 i = new vec4.zero();
   vec4 j = new vec4.zero();
   vec4 k = new vec4.zero();
   i.x = invDet * (col1.y * col2.z - col1.z * col2.y);
   i.y = invDet * (col0.z * col2.y - col0.y * col2.z);
   i.z = invDet * (col0.y * col1.z - col0.z * col1.y);
   j.x = invDet * (col1.z * col2.x - col1.x * col2.z);
   j.y = invDet * (col0.x * col2.z - col0.z * col2.x);
   j.z = invDet * (col0.z * col1.x - col0.x * col1.z);
   k.x = invDet * (col1.x * col2.y - col1.y * col2.x);
   k.y = invDet * (col0.y * col2.x - col0.x * col2.y);
   k.z = invDet * (col0.x * col1.y - col0.y * col1.x);
   col0 = i;
   col1 = j;
   col2 = k;
   return det;
 }
 /// Sets the upper 3x3 to a rotation of [radians] around X
 void setRotationX(num radians) {
   double radians_ = radians.toDouble();
   double c = Math.cos(radians_);
   double s = Math.sin(radians_);
   col0.x = 1.0;
   col0.y = 0.0;
   col0.z = 0.0;
   col1.x = 0.0;
   col1.y = c;
   col1.z = s;
   col2.x = 0.0;
   col2.y = -s;
   col2.z = c;
   col0.w = 0.0;
   col1.w = 0.0;
   col2.w = 0.0;
 }
 /// Sets the upper 3x3 to a rotation of [radians] around Y
 void setRotationY(num radians) {
   double radians_ = radians.toDouble();
   double c = Math.cos(radians_);
   double s = Math.sin(radians_);
   col0.x = c;
   col0.y = 0.0;
   col0.z = s;
   col1.x = 0.0;
   col1.y = 1.0;
   col1.z = 0.0;
   col2.x = -s;
   col2.y = 0.0;
   col2.z = c;
   col0.w = 0.0;
   col1.w = 0.0;
   col2.w = 0.0;
 }
 /// Sets the upper 3x3 to a rotation of [radians] around Z
 void setRotationZ(num radians) {
   double radians_ = radians.toDouble();
   double c = Math.cos(radians_);
   double s = Math.sin(radians_);
   col0.x = c;
   col0.y = s;
   col0.z = 0.0;
   col1.x = -s;
   col1.y = c;
   col1.z = 0.0;
   col2.x = 0.0;
   col2.y = 0.0;
   col2.z = 1.0;
   col0.w = 0.0;
   col1.w = 0.0;
   col2.w = 0.0;
 }
 /// Converts into Adjugate matrix and scales by [scale]
 mat4 scaleAdjoint(num scale) {
   double scale_ = scale.toDouble();
   // Adapted from code by Richard Carling.
   double a1 = col0.x;
   double b1 = col1.x;
   double c1 = col2.x;
   double d1 = col3.x;
   double a2 = col0.y;
   double b2 = col1.y;
   double c2 = col2.y;
   double d2 = col3.y;
   double a3 = col0.z;
   double b3 = col1.z;
   double c3 = col2.z;
   double d3 = col3.z;
   double a4 = col0.w;
   double b4 = col1.w;
   double c4 = col2.w;
   double d4 = col3.w;
   col0.x  =   (b2 * (c3 * d4 - c4 * d3) - c2 * (b3 * d4 - b4 * d3) + d2 * (b3 * c4 - b4 * c3)) * scale_;
   col0.y  = - (a2 * (c3 * d4 - c4 * d3) - c2 * (a3 * d4 - a4 * d3) + d2 * (a3 * c4 - a4 * c3)) * scale_;
   col0.z  =   (a2 * (b3 * d4 - b4 * d3) - b2 * (a3 * d4 - a4 * d3) + d2 * (a3 * b4 - a4 * b3)) * scale_;
   col0.w  = - (a2 * (b3 * c4 - b4 * c3) - b2 * (a3 * c4 - a4 * c3) + c2 * (a3 * b4 - a4 * b3)) * scale_;
   col1.x  = - (b1 * (c3 * d4 - c4 * d3) - c1 * (b3 * d4 - b4 * d3) + d1 * (b3 * c4 - b4 * c3)) * scale_;
   col1.y  =   (a1 * (c3 * d4 - c4 * d3) - c1 * (a3 * d4 - a4 * d3) + d1 * (a3 * c4 - a4 * c3)) * scale_;
   col1.z  = - (a1 * (b3 * d4 - b4 * d3) - b1 * (a3 * d4 - a4 * d3) + d1 * (a3 * b4 - a4 * b3)) * scale_;
   col1.w  =   (a1 * (b3 * c4 - b4 * c3) - b1 * (a3 * c4 - a4 * c3) + c1 * (a3 * b4 - a4 * b3)) * scale_;
   col2.x  =   (b1 * (c2 * d4 - c4 * d2) - c1 * (b2 * d4 - b4 * d2) + d1 * (b2 * c4 - b4 * c2)) * scale_;
   col2.y  = - (a1 * (c2 * d4 - c4 * d2) - c1 * (a2 * d4 - a4 * d2) + d1 * (a2 * c4 - a4 * c2)) * scale_;
   col2.z  =   (a1 * (b2 * d4 - b4 * d2) - b1 * (a2 * d4 - a4 * d2) + d1 * (a2 * b4 - a4 * b2)) * scale_;
   col2.w  = - (a1 * (b2 * c4 - b4 * c2) - b1 * (a2 * c4 - a4 * c2) + c1 * (a2 * b4 - a4 * b2)) * scale_;
   col3.x  = - (b1 * (c2 * d3 - c3 * d2) - c1 * (b2 * d3 - b3 * d2) + d1 * (b2 * c3 - b3 * c2)) * scale_;
   col3.y  =   (a1 * (c2 * d3 - c3 * d2) - c1 * (a2 * d3 - a3 * d2) + d1 * (a2 * c3 - a3 * c2)) * scale_;
   col3.z  = - (a1 * (b2 * d3 - b3 * d2) - b1 * (a2 * d3 - a3 * d2) + d1 * (a2 * b3 - a3 * b2)) * scale_;
   col3.w  =   (a1 * (b2 * c3 - b3 * c2) - b1 * (a2 * c3 - a3 * c2) + c1 * (a2 * b3 - a3 * b2)) * scale_;
   return this;
 }
 /// Rotates [arg] by the absolute rotation of [this]
 /// Returns [arg].
 /// Primarily used by AABB transformation code.
 vec3 absoluteRotate(vec3 arg) {
   double m00 = col0.x.abs();
   double m01 = col1.x.abs();
   double m02 = col2.x.abs();
   double m10 = col0.y.abs();
   double m11 = col1.y.abs();
   double m12 = col2.y.abs();
   double m20 = col0.z.abs();
   double m21 = col1.z.abs();
   double m22 = col2.z.abs();
   double x = arg.x;
   double y = arg.y;
   double z = arg.z;
   arg.x = x * m00 + y * m01 + z * m02 + 0.0 * 0.0;
   arg.y = x * m10 + y * m11 + z * m12 + 0.0 * 0.0;
   arg.z = x * m20 + y * m21 + z * m22 + 0.0 * 0.0;
   return arg;
 }
 mat4 clone() {
   return new mat4.copy(this);
 }
 mat4 copyInto(mat4 arg) {
   arg.col0.x = col0.x;
   arg.col0.y = col0.y;
   arg.col0.z = col0.z;
   arg.col0.w = col0.w;
   arg.col1.x = col1.x;
   arg.col1.y = col1.y;
   arg.col1.z = col1.z;
   arg.col1.w = col1.w;
   arg.col2.x = col2.x;
   arg.col2.y = col2.y;
   arg.col2.z = col2.z;
   arg.col2.w = col2.w;
   arg.col3.x = col3.x;
   arg.col3.y = col3.y;
   arg.col3.z = col3.z;
   arg.col3.w = col3.w;
   return arg;
 }
 mat4 copyFrom(mat4 arg) {
   col0.x = arg.col0.x;
   col0.y = arg.col0.y;
   col0.z = arg.col0.z;
   col0.w = arg.col0.w;
   col1.x = arg.col1.x;
   col1.y = arg.col1.y;
   col1.z = arg.col1.z;
   col1.w = arg.col1.w;
   col2.x = arg.col2.x;
   col2.y = arg.col2.y;
   col2.z = arg.col2.z;
   col2.w = arg.col2.w;
   col3.x = arg.col3.x;
   col3.y = arg.col3.y;
   col3.z = arg.col3.z;
   col3.w = arg.col3.w;
   return this;
 }
 mat4 add(mat4 o) {
   col0.x = col0.x + o.col0.x;
   col0.y = col0.y + o.col0.y;
   col0.z = col0.z + o.col0.z;
   col0.w = col0.w + o.col0.w;
   col1.x = col1.x + o.col1.x;
   col1.y = col1.y + o.col1.y;
   col1.z = col1.z + o.col1.z;
   col1.w = col1.w + o.col1.w;
   col2.x = col2.x + o.col2.x;
   col2.y = col2.y + o.col2.y;
   col2.z = col2.z + o.col2.z;
   col2.w = col2.w + o.col2.w;
   col3.x = col3.x + o.col3.x;
   col3.y = col3.y + o.col3.y;
   col3.z = col3.z + o.col3.z;
   col3.w = col3.w + o.col3.w;
   return this;
 }
 mat4 sub(mat4 o) {
   col0.x = col0.x - o.col0.x;
   col0.y = col0.y - o.col0.y;
   col0.z = col0.z - o.col0.z;
   col0.w = col0.w - o.col0.w;
   col1.x = col1.x - o.col1.x;
   col1.y = col1.y - o.col1.y;
   col1.z = col1.z - o.col1.z;
   col1.w = col1.w - o.col1.w;
   col2.x = col2.x - o.col2.x;
   col2.y = col2.y - o.col2.y;
   col2.z = col2.z - o.col2.z;
   col2.w = col2.w - o.col2.w;
   col3.x = col3.x - o.col3.x;
   col3.y = col3.y - o.col3.y;
   col3.z = col3.z - o.col3.z;
   col3.w = col3.w - o.col3.w;
   return this;
 }
 mat4 negate() {
   col0.x = -col0.x;
   col0.y = -col0.y;
   col0.z = -col0.z;
   col0.w = -col0.w;
   col1.x = -col1.x;
   col1.y = -col1.y;
   col1.z = -col1.z;
   col1.w = -col1.w;
   col2.x = -col2.x;
   col2.y = -col2.y;
   col2.z = -col2.z;
   col2.w = -col2.w;
   col3.x = -col3.x;
   col3.y = -col3.y;
   col3.z = -col3.z;
   col3.w = -col3.w;
   return this;
 }
 mat4 multiply(mat4 arg) {
   final double m00 = col0.x;
   final double m01 = col1.x;
   final double m02 = col2.x;
   final double m03 = col3.x;
   final double m10 = col0.y;
   final double m11 = col1.y;
   final double m12 = col2.y;
   final double m13 = col3.y;
   final double m20 = col0.z;
   final double m21 = col1.z;
   final double m22 = col2.z;
   final double m23 = col3.z;
   final double m30 = col0.w;
   final double m31 = col1.w;
   final double m32 = col2.w;
   final double m33 = col3.w;
   final double n00 = arg.col0.x;
   final double n01 = arg.col1.x;
   final double n02 = arg.col2.x;
   final double n03 = arg.col3.x;
   final double n10 = arg.col0.y;
   final double n11 = arg.col1.y;
   final double n12 = arg.col2.y;
   final double n13 = arg.col3.y;
   final double n20 = arg.col0.z;
   final double n21 = arg.col1.z;
   final double n22 = arg.col2.z;
   final double n23 = arg.col3.z;
   final double n30 = arg.col0.w;
   final double n31 = arg.col1.w;
   final double n32 = arg.col2.w;
   final double n33 = arg.col3.w;
   col0.x =  (m00 * n00) + (m01 * n10) + (m02 * n20) + (m03 * n30);
   col1.x =  (m00 * n01) + (m01 * n11) + (m02 * n21) + (m03 * n31);
   col2.x =  (m00 * n02) + (m01 * n12) + (m02 * n22) + (m03 * n32);
   col3.x =  (m00 * n03) + (m01 * n13) + (m02 * n23) + (m03 * n33);
   col0.y =  (m10 * n00) + (m11 * n10) + (m12 * n20) + (m13 * n30);
   col1.y =  (m10 * n01) + (m11 * n11) + (m12 * n21) + (m13 * n31);
   col2.y =  (m10 * n02) + (m11 * n12) + (m12 * n22) + (m13 * n32);
   col3.y =  (m10 * n03) + (m11 * n13) + (m12 * n23) + (m13 * n33);
   col0.z =  (m20 * n00) + (m21 * n10) + (m22 * n20) + (m23 * n30);
   col1.z =  (m20 * n01) + (m21 * n11) + (m22 * n21) + (m23 * n31);
   col2.z =  (m20 * n02) + (m21 * n12) + (m22 * n22) + (m23 * n32);
   col3.z =  (m20 * n03) + (m21 * n13) + (m22 * n23) + (m23 * n33);
   col0.w =  (m30 * n00) + (m31 * n10) + (m32 * n20) + (m33 * n30);
   col1.w =  (m30 * n01) + (m31 * n11) + (m32 * n21) + (m33 * n31);
   col2.w =  (m30 * n02) + (m31 * n12) + (m32 * n22) + (m33 * n32);
   col3.w =  (m30 * n03) + (m31 * n13) + (m32 * n23) + (m33 * n33);
   return this;
 }
 mat4 transposeMultiply(mat4 arg) {
   double m00 = col0.x;
   double m01 = col0.y;
   double m02 = col0.z;
   double m03 = col0.w;
   double m10 = col1.x;
   double m11 = col1.y;
   double m12 = col1.z;
   double m13 = col1.w;
   double m20 = col2.x;
   double m21 = col2.y;
   double m22 = col2.z;
   double m23 = col2.w;
   double m30 = col3.x;
   double m31 = col3.y;
   double m32 = col3.z;
   double m33 = col3.w;
   col0.x =  (m00 * arg.col0.x) + (m01 * arg.col0.y) + (m02 * arg.col0.z) + (m03 * arg.col0.w);
   col1.x =  (m00 * arg.col1.x) + (m01 * arg.col1.y) + (m02 * arg.col1.z) + (m03 * arg.col1.w);
   col2.x =  (m00 * arg.col2.x) + (m01 * arg.col2.y) + (m02 * arg.col2.z) + (m03 * arg.col2.w);
   col3.x =  (m00 * arg.col3.x) + (m01 * arg.col3.y) + (m02 * arg.col3.z) + (m03 * arg.col3.w);
   col0.y =  (m10 * arg.col0.x) + (m11 * arg.col0.y) + (m12 * arg.col0.z) + (m13 * arg.col0.w);
   col1.y =  (m10 * arg.col1.x) + (m11 * arg.col1.y) + (m12 * arg.col1.z) + (m13 * arg.col1.w);
   col2.y =  (m10 * arg.col2.x) + (m11 * arg.col2.y) + (m12 * arg.col2.z) + (m13 * arg.col2.w);
   col3.y =  (m10 * arg.col3.x) + (m11 * arg.col3.y) + (m12 * arg.col3.z) + (m13 * arg.col3.w);
   col0.z =  (m20 * arg.col0.x) + (m21 * arg.col0.y) + (m22 * arg.col0.z) + (m23 * arg.col0.w);
   col1.z =  (m20 * arg.col1.x) + (m21 * arg.col1.y) + (m22 * arg.col1.z) + (m23 * arg.col1.w);
   col2.z =  (m20 * arg.col2.x) + (m21 * arg.col2.y) + (m22 * arg.col2.z) + (m23 * arg.col2.w);
   col3.z =  (m20 * arg.col3.x) + (m21 * arg.col3.y) + (m22 * arg.col3.z) + (m23 * arg.col3.w);
   col0.w =  (m30 * arg.col0.x) + (m31 * arg.col0.y) + (m32 * arg.col0.z) + (m33 * arg.col0.w);
   col1.w =  (m30 * arg.col1.x) + (m31 * arg.col1.y) + (m32 * arg.col1.z) + (m33 * arg.col1.w);
   col2.w =  (m30 * arg.col2.x) + (m31 * arg.col2.y) + (m32 * arg.col2.z) + (m33 * arg.col2.w);
   col3.w =  (m30 * arg.col3.x) + (m31 * arg.col3.y) + (m32 * arg.col3.z) + (m33 * arg.col3.w);
   return this;
 }
 mat4 multiplyTranspose(mat4 arg) {
   double m00 = col0.x;
   double m01 = col1.x;
   double m02 = col2.x;
   double m03 = col3.x;
   double m10 = col0.y;
   double m11 = col1.y;
   double m12 = col2.y;
   double m13 = col3.y;
   double m20 = col0.z;
   double m21 = col1.z;
   double m22 = col2.z;
   double m23 = col3.z;
   double m30 = col0.w;
   double m31 = col1.w;
   double m32 = col2.w;
   double m33 = col3.w;
   col0.x =  (m00 * arg.col0.x) + (m01 * arg.col1.x) + (m02 * arg.col2.x) + (m03 * arg.col3.x);
   col1.x =  (m00 * arg.col0.y) + (m01 * arg.col1.y) + (m02 * arg.col2.y) + (m03 * arg.col3.y);
   col2.x =  (m00 * arg.col0.z) + (m01 * arg.col1.z) + (m02 * arg.col2.z) + (m03 * arg.col3.z);
   col3.x =  (m00 * arg.col0.w) + (m01 * arg.col1.w) + (m02 * arg.col2.w) + (m03 * arg.col3.w);
   col0.y =  (m10 * arg.col0.x) + (m11 * arg.col1.x) + (m12 * arg.col2.x) + (m13 * arg.col3.x);
   col1.y =  (m10 * arg.col0.y) + (m11 * arg.col1.y) + (m12 * arg.col2.y) + (m13 * arg.col3.y);
   col2.y =  (m10 * arg.col0.z) + (m11 * arg.col1.z) + (m12 * arg.col2.z) + (m13 * arg.col3.z);
   col3.y =  (m10 * arg.col0.w) + (m11 * arg.col1.w) + (m12 * arg.col2.w) + (m13 * arg.col3.w);
   col0.z =  (m20 * arg.col0.x) + (m21 * arg.col1.x) + (m22 * arg.col2.x) + (m23 * arg.col3.x);
   col1.z =  (m20 * arg.col0.y) + (m21 * arg.col1.y) + (m22 * arg.col2.y) + (m23 * arg.col3.y);
   col2.z =  (m20 * arg.col0.z) + (m21 * arg.col1.z) + (m22 * arg.col2.z) + (m23 * arg.col3.z);
   col3.z =  (m20 * arg.col0.w) + (m21 * arg.col1.w) + (m22 * arg.col2.w) + (m23 * arg.col3.w);
   col0.w =  (m30 * arg.col0.x) + (m31 * arg.col1.x) + (m32 * arg.col2.x) + (m33 * arg.col3.x);
   col1.w =  (m30 * arg.col0.y) + (m31 * arg.col1.y) + (m32 * arg.col2.y) + (m33 * arg.col3.y);
   col2.w =  (m30 * arg.col0.z) + (m31 * arg.col1.z) + (m32 * arg.col2.z) + (m33 * arg.col3.z);
   col3.w =  (m30 * arg.col0.w) + (m31 * arg.col1.w) + (m32 * arg.col2.w) + (m33 * arg.col3.w);
   return this;
 }
 vec3 rotate3(vec3 arg) {
   double x_ =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z);
   double y_ =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z);
   double z_ =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z);
   arg.x = x_;
   arg.y = y_;
   arg.z = z_;
   return arg;
 }
 vec3 rotated3(vec3 arg, [vec3 out=null]) {
   if (out == null) {
     out = new vec3.copy(arg);
   } else {
     out.copyFrom(arg);
   }
   return rotate3(out);
 }
 vec3 transform3(vec3 arg) {
   double x_ =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + col3.x;
   double y_ =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + col3.y;
   double z_ =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + col3.z;
   arg.x = x_;
   arg.y = y_;
   arg.z = z_;
   return arg;
 }
 vec3 transformed3(vec3 arg, [vec3 out=null]) {
   if (out == null) {
     out = new vec3.copy(arg);
   } else {
     out.copyFrom(arg);
   }
   return transform3(out);
 }
 vec4 transform(vec4 arg) {
   double x_ =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + (this.col3.x * arg.w);
   double y_ =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + (this.col3.y * arg.w);
   double z_ =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + (this.col3.z * arg.w);
   double w_ =  (this.col0.w * arg.x) + (this.col1.w * arg.y) + (this.col2.w * arg.z) + (this.col3.w * arg.w);
   arg.x = x_;
   arg.y = y_;
   arg.z = z_;
   arg.w = w_;
   return arg;
 }
 vec4 transformed(vec4 arg, [vec4 out=null]) {
   if (out == null) {
     out = new vec4.copy(arg);
   } else {
     out.copyFrom(arg);
   }
   return transform(out);
 }
 /// Copies [this] into [array] starting at [offset].
 void copyIntoArray(List&lt;num&gt; array, [int offset=0]) {
   int i = offset;
   array[i] = col0.x;
   i++;
   array[i] = col0.y;
   i++;
   array[i] = col0.z;
   i++;
   array[i] = col0.w;
   i++;
   array[i] = col1.x;
   i++;
   array[i] = col1.y;
   i++;
   array[i] = col1.z;
   i++;
   array[i] = col1.w;
   i++;
   array[i] = col2.x;
   i++;
   array[i] = col2.y;
   i++;
   array[i] = col2.z;
   i++;
   array[i] = col2.w;
   i++;
   array[i] = col3.x;
   i++;
   array[i] = col3.y;
   i++;
   array[i] = col3.z;
   i++;
   array[i] = col3.w;
   i++;
 }
 /// Copies elements from [array] into [this] starting at [offset].
 void copyFromArray(List&lt;num&gt; array, [int offset=0]) {
   int i = offset;
   col0.x = array[i].toDouble();
   i++;
   col0.y = array[i].toDouble();
   i++;
   col0.z = array[i].toDouble();
   i++;
   col0.w = array[i].toDouble();
   i++;
   col1.x = array[i].toDouble();
   i++;
   col1.y = array[i].toDouble();
   i++;
   col1.z = array[i].toDouble();
   i++;
   col1.w = array[i].toDouble();
   i++;
   col2.x = array[i].toDouble();
   i++;
   col2.y = array[i].toDouble();
   i++;
   col2.z = array[i].toDouble();
   i++;
   col2.w = array[i].toDouble();
   i++;
   col3.x = array[i].toDouble();
   i++;
   col3.y = array[i].toDouble();
   i++;
   col3.z = array[i].toDouble();
   i++;
   col3.w = array[i].toDouble();
   i++;
 }
 vec3 get right {
   vec3 f = new vec3.zero();
   f.x = col0.x;
   f.y = col0.y;
   f.z = col0.z;
   return f;
 }
 vec3 get up {
   vec3 f = new vec3.zero();
   f.x = col1.x;
   f.y = col1.y;
   f.z = col1.z;
   return f;
 }
 vec3 get forward {
   vec3 f = new vec3.zero();
   f.x = col2.x;
   f.y = col2.y;
   f.z = col2.z;
   return f;
 }
}
</pre>
</div>
<div>
<h3>Constructors</h3>
<div class="method"><h4 id="mat4">
<button class="show-code">Code</button>
new <strong>mat4</strong>([arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15]) <a class="anchor-link" href="#mat4"
              title="Permalink to mat4.mat4">#</a></h4>
<div class="doc">
<p>Constructs a new mat4. Supports GLSL like syntax so many possible inputs. Defaults to identity matrix.</p>
<pre class="source">
mat4([dynamic arg0, dynamic arg1, dynamic arg2, dynamic arg3, dynamic arg4, dynamic arg5, dynamic arg6, dynamic arg7, dynamic arg8, dynamic arg9, dynamic arg10, dynamic arg11, dynamic arg12, dynamic arg13, dynamic arg14, dynamic arg15]) {
 //Initialize the matrix as the identity matrix
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = 1.0;
 col1.y = 1.0;
 col2.z = 1.0;
 col3.w = 1.0;
 if (arg0 is num &amp;&amp; arg1 is num &amp;&amp; arg2 is num &amp;&amp; arg3 is num &amp;&amp; arg4 is num &amp;&amp; arg5 is num &amp;&amp; arg6 is num &amp;&amp; arg7 is num &amp;&amp; arg8 is num &amp;&amp; arg9 is num &amp;&amp; arg10 is num &amp;&amp; arg11 is num &amp;&amp; arg12 is num &amp;&amp; arg13 is num &amp;&amp; arg14 is num &amp;&amp; arg15 is num) {
   col0.x = arg0;
   col0.y = arg1;
   col0.z = arg2;
   col0.w = arg3;
   col1.x = arg4;
   col1.y = arg5;
   col1.z = arg6;
   col1.w = arg7;
   col2.x = arg8;
   col2.y = arg9;
   col2.z = arg10;
   col2.w = arg11;
   col3.x = arg12;
   col3.y = arg13;
   col3.z = arg14;
   col3.w = arg15;
   return;
 }
 if (arg0 is num &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
   col0.x = arg0;
   col1.y = arg0;
   col2.z = arg0;
   col3.w = arg0;
   return;
 }
 if (arg0 is vec4 &amp;&amp; arg1 is vec4 &amp;&amp; arg2 is vec4 &amp;&amp; arg3 is vec4) {
   col0 = arg0;
   col1 = arg1;
   col2 = arg2;
   col3 = arg3;
   return;
 }
 if (arg0 is mat4) {
   col0 = arg0.col0;
   col1 = arg0.col1;
   col2 = arg0.col2;
   col3 = arg0.col3;
   return;
 }
 if (arg0 is mat3) {
   col0.x = arg0.col0.x;
   col0.y = arg0.col0.y;
   col0.z = arg0.col0.z;
   col1.x = arg0.col1.x;
   col1.y = arg0.col1.y;
   col1.z = arg0.col1.z;
   col2.x = arg0.col2.x;
   col2.y = arg0.col2.y;
   col2.z = arg0.col2.z;
   return;
 }
 if (arg0 is mat2) {
   col0.x = arg0.col0.x;
   col0.y = arg0.col0.y;
   col1.x = arg0.col1.x;
   col1.y = arg0.col1.y;
   return;
 }
 if (arg0 is vec2 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
   col0.x = arg0.x;
   col1.y = arg0.y;
 }
 if (arg0 is vec3 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
   col0.x = arg0.x;
   col1.y = arg0.y;
   col2.z = arg0.z;
 }
 if (arg0 is vec4 &amp;&amp; arg1 == null &amp;&amp; arg2 == null &amp;&amp; arg3 == null &amp;&amp; arg4 == null &amp;&amp; arg5 == null &amp;&amp; arg6 == null &amp;&amp; arg7 == null &amp;&amp; arg8 == null &amp;&amp; arg9 == null &amp;&amp; arg10 == null &amp;&amp; arg11 == null &amp;&amp; arg12 == null &amp;&amp; arg13 == null &amp;&amp; arg14 == null &amp;&amp; arg15 == null) {
   col0.x = arg0.x;
   col1.y = arg0.y;
   col2.z = arg0.z;
   col3.w = arg0.w;
 }
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.copy">
<button class="show-code">Code</button>
new <strong>mat4.copy</strong>(<a href="../vector_math/mat4.html">mat4</a> other) <a class="anchor-link" href="#mat4.copy"
              title="Permalink to mat4.mat4.copy">#</a></h4>
<div class="doc">
<p>Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> which is a copy of 
<span class="param">other</span>.</p>
<pre class="source">
mat4.copy(mat4 other) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = other.col0.x;
 col0.y = other.col0.y;
 col0.z = other.col0.z;
 col0.w = other.col0.w;
 col1.x = other.col1.x;
 col1.y = other.col1.y;
 col1.z = other.col1.z;
 col1.w = other.col1.w;
 col2.x = other.col2.x;
 col2.y = other.col2.y;
 col2.z = other.col2.z;
 col2.w = other.col2.w;
 col3.x = other.col3.x;
 col3.y = other.col3.y;
 col3.z = other.col3.z;
 col3.w = other.col3.w;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.identity">
<button class="show-code">Code</button>
new <strong>mat4.identity</strong>() <a class="anchor-link" href="#mat4.identity"
              title="Permalink to mat4.mat4.identity">#</a></h4>
<div class="doc">
<p>Constructs a new identity <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a>.</p>
<pre class="source">
mat4.identity() {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = 1.0;
 col1.y = 1.0;
 col2.z = 1.0;
 col3.w = 1.0;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.outer">
<button class="show-code">Code</button>
new <strong>mat4.outer</strong>(<a href="../vector_math/vec4.html">vec4</a> u, <a href="../vector_math/vec4.html">vec4</a> v) <a class="anchor-link" href="#mat4.outer"
              title="Permalink to mat4.mat4.outer">#</a></h4>
<div class="doc">
<p>Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> from computing the outer product of 
<span class="param">u</span> and 
<span class="param">v</span>.</p>
<pre class="source">
mat4.outer(vec4 u, vec4 v) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = u.x * v.x;
 col0.y = u.x * v.y;
 col0.z = u.x * v.z;
 col0.w = u.x * v.w;
 col1.x = u.y * v.x;
 col1.y = u.y * v.y;
 col1.z = u.y * v.z;
 col1.w = u.y * v.w;
 col2.x = u.z * v.x;
 col2.y = u.z * v.y;
 col2.z = u.z * v.z;
 col2.w = u.z * v.w;
 col3.x = u.w * v.x;
 col3.y = u.w * v.y;
 col3.z = u.w * v.z;
 col3.w = u.w * v.w;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.raw">
<button class="show-code">Code</button>
new <strong>mat4.raw</strong>(num arg0, num arg1, num arg2, num arg3, num arg4, num arg5, num arg6, num arg7, num arg8, num arg9, num arg10, num arg11, num arg12, num arg13, num arg14, num arg15) <a class="anchor-link" href="#mat4.raw"
              title="Permalink to mat4.mat4.raw">#</a></h4>
<div class="doc">
<pre class="source">
mat4.raw(num arg0, num arg1, num arg2, num arg3, num arg4, num arg5, num arg6, num arg7, num arg8, num arg9, num arg10, num arg11, num arg12, num arg13, num arg14, num arg15) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = arg0;
 col0.y = arg1;
 col0.z = arg2;
 col0.w = arg3;
 col1.x = arg4;
 col1.y = arg5;
 col1.z = arg6;
 col1.w = arg7;
 col2.x = arg8;
 col2.y = arg9;
 col2.z = arg10;
 col2.w = arg11;
 col3.x = arg12;
 col3.y = arg13;
 col3.z = arg14;
 col3.w = arg15;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.rotationX">
<button class="show-code">Code</button>
new <strong>mat4.rotationX</strong>(num radians_) <a class="anchor-link" href="#mat4.rotationX"
              title="Permalink to mat4.mat4.rotationX">#</a></h4>
<div class="doc">
<p>/ Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> representation a rotation of <a class="crossref" href="../vector_math.html#radians">radians</a> around the X axis</p>
<pre class="source">
mat4.rotationX(num radians_) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col3.w = 1.0;
 setRotationX(radians_);
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.rotationY">
<button class="show-code">Code</button>
new <strong>mat4.rotationY</strong>(num radians_) <a class="anchor-link" href="#mat4.rotationY"
              title="Permalink to mat4.mat4.rotationY">#</a></h4>
<div class="doc">
<p>/ Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> representation a rotation of <a class="crossref" href="../vector_math.html#radians">radians</a> around the Y axis</p>
<pre class="source">
mat4.rotationY(num radians_) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col3.w = 1.0;
 setRotationY(radians_);
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.rotationZ">
<button class="show-code">Code</button>
new <strong>mat4.rotationZ</strong>(num radians_) <a class="anchor-link" href="#mat4.rotationZ"
              title="Permalink to mat4.mat4.rotationZ">#</a></h4>
<div class="doc">
<p>/ Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> representation a rotation of <a class="crossref" href="../vector_math.html#radians">radians</a> around the Z axis</p>
<pre class="source">
mat4.rotationZ(num radians_) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col3.w = 1.0;
 setRotationZ(radians_);
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.scaleRaw">
<button class="show-code">Code</button>
new <strong>mat4.scaleRaw</strong>(num x, num y, num z) <a class="anchor-link" href="#mat4.scaleRaw"
              title="Permalink to mat4.mat4.scaleRaw">#</a></h4>
<div class="doc">
<p>/ Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> representening a scale of 
<span class="param">x</span>, 
<span class="param">y</span>, and 
<span class="param">z</span></p>
<pre class="source">
mat4.scaleRaw(num x, num y, num z) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = x;
 col1.y = y;
 col2.z = z;
 col3.w = 1.0;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.scaleVec">
<button class="show-code">Code</button>
new <strong>mat4.scaleVec</strong>(<a href="../vector_math/vec3.html">vec3</a> scale_) <a class="anchor-link" href="#mat4.scaleVec"
              title="Permalink to mat4.mat4.scaleVec">#</a></h4>
<div class="doc">
<p>/ Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> scale of <code>x</code>, <code>y</code>, and <code>z</code></p>
<pre class="source">
mat4.scaleVec(vec3 scale_) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = scale_.x;
 col1.y = scale_.y;
 col2.z = scale_.z;
 col3.w = 1.0;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.translation">
<button class="show-code">Code</button>
new <strong>mat4.translation</strong>(<a href="../vector_math/vec3.html">vec3</a> translation) <a class="anchor-link" href="#mat4.translation"
              title="Permalink to mat4.mat4.translation">#</a></h4>
<div class="doc">
<p>Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> translation matrix from 
<span class="param">translation</span></p>
<pre class="source">
mat4.translation(vec3 translation) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = 1.0;
 col1.y = 1.0;
 col2.z = 1.0;
 col3.w = 1.0;
 col3.xyz = translation;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.translationRaw">
<button class="show-code">Code</button>
new <strong>mat4.translationRaw</strong>(num x, num y, num z) <a class="anchor-link" href="#mat4.translationRaw"
              title="Permalink to mat4.mat4.translationRaw">#</a></h4>
<div class="doc">
<p>Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> translation from 
<span class="param">x</span>, 
<span class="param">y</span>, and 
<span class="param">z</span></p>
<pre class="source">
mat4.translationRaw(num x, num y, num z) {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = 1.0;
 col1.y = 1.0;
 col2.z = 1.0;
 col3.w = 1.0;
 col3.x = x;
 col3.y = y;
 col3.z = z;
}
</pre>
</div>
</div>
<div class="method"><h4 id="mat4.zero">
<button class="show-code">Code</button>
new <strong>mat4.zero</strong>() <a class="anchor-link" href="#mat4.zero"
              title="Permalink to mat4.mat4.zero">#</a></h4>
<div class="doc">
<p>Constructs a new <a class="crossref" href="../vector_math/mat4.html#mat4">mat4</a> filled with zeros.</p>
<pre class="source">
mat4.zero() {
 col0 = new vec4.zero();
 col1 = new vec4.zero();
 col2 = new vec4.zero();
 col3 = new vec4.zero();
 col0.x = 0.0;
 col0.y = 0.0;
 col0.z = 0.0;
 col0.w = 0.0;
 col1.x = 0.0;
 col1.y = 0.0;
 col1.z = 0.0;
 col1.w = 0.0;
 col2.x = 0.0;
 col2.y = 0.0;
 col2.z = 0.0;
 col2.w = 0.0;
 col3.x = 0.0;
 col3.y = 0.0;
 col3.z = 0.0;
 col3.w = 0.0;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Properties</h3>
<div class="field"><h4 id="col0">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a>         <strong>col0</strong> <a class="anchor-link"
            href="#col0"
            title="Permalink to mat4.col0">#</a>
        </h4>
        <div class="doc">
<pre class="source">
col0
</pre>
</div>
</div>
<div class="field"><h4 id="col1">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a>         <strong>col1</strong> <a class="anchor-link"
            href="#col1"
            title="Permalink to mat4.col1">#</a>
        </h4>
        <div class="doc">
<pre class="source">
col1
</pre>
</div>
</div>
<div class="field"><h4 id="col2">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a>         <strong>col2</strong> <a class="anchor-link"
            href="#col2"
            title="Permalink to mat4.col2">#</a>
        </h4>
        <div class="doc">
<pre class="source">
col2
</pre>
</div>
</div>
<div class="field"><h4 id="col3">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a>         <strong>col3</strong> <a class="anchor-link"
            href="#col3"
            title="Permalink to mat4.col3">#</a>
        </h4>
        <div class="doc">
<pre class="source">
col3
</pre>
</div>
</div>
<div class="field"><h4 id="cols">
<button class="show-code">Code</button>
final int         <strong>cols</strong> <a class="anchor-link"
            href="#cols"
            title="Permalink to mat4.cols">#</a>
        </h4>
        <div class="doc">
<p>Returns the number of columns in the matrix.</p>
<pre class="source">
int get cols =&gt; 4;
</pre>
</div>
</div>
<div class="field"><h4 id="forward">
<button class="show-code">Code</button>
final <a href="../vector_math/vec3.html">vec3</a>         <strong>forward</strong> <a class="anchor-link"
            href="#forward"
            title="Permalink to mat4.forward">#</a>
        </h4>
        <div class="doc">
<pre class="source">
vec3 get forward {
 vec3 f = new vec3.zero();
 f.x = col2.x;
 f.y = col2.y;
 f.z = col2.z;
 return f;
}
</pre>
</div>
</div>
<div class="field"><h4 id="length">
<button class="show-code">Code</button>
final int         <strong>length</strong> <a class="anchor-link"
            href="#length"
            title="Permalink to mat4.length">#</a>
        </h4>
        <div class="doc">
<p>Returns the number of columns in the matrix.</p>
<pre class="source">
int get length =&gt; 4;
</pre>
</div>
</div>
<div class="field"><h4 id="right">
<button class="show-code">Code</button>
final <a href="../vector_math/vec3.html">vec3</a>         <strong>right</strong> <a class="anchor-link"
            href="#right"
            title="Permalink to mat4.right">#</a>
        </h4>
        <div class="doc">
<pre class="source">
vec3 get right {
 vec3 f = new vec3.zero();
 f.x = col0.x;
 f.y = col0.y;
 f.z = col0.z;
 return f;
}
</pre>
</div>
</div>
<div class="method"><h4 id="row0">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>get row0</strong> <a class="anchor-link" href="#row0"
              title="Permalink to mat4.get row0">#</a></h4>
<div class="doc">
<p>Returns row 0</p>
<pre class="source">
vec4 get row0 =&gt; getRow(0);
</pre>
</div>
</div>
<div class="method"><h4 id="row0=">
<button class="show-code">Code</button>
<strong>set row0</strong>(<a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#row0="
              title="Permalink to mat4.set row0">#</a></h4>
<div class="doc">
<p>Sets row 0 to 
<span class="param">arg</span></p>
<pre class="source">
set row0(vec4 arg) =&gt; setRow(0, arg);
</pre>
</div>
</div>
<div class="method"><h4 id="row1">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>get row1</strong> <a class="anchor-link" href="#row1"
              title="Permalink to mat4.get row1">#</a></h4>
<div class="doc">
<p>Returns row 1</p>
<pre class="source">
vec4 get row1 =&gt; getRow(1);
</pre>
</div>
</div>
<div class="method"><h4 id="row1=">
<button class="show-code">Code</button>
<strong>set row1</strong>(<a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#row1="
              title="Permalink to mat4.set row1">#</a></h4>
<div class="doc">
<p>Sets row 1 to 
<span class="param">arg</span></p>
<pre class="source">
set row1(vec4 arg) =&gt; setRow(1, arg);
</pre>
</div>
</div>
<div class="method"><h4 id="row2">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>get row2</strong> <a class="anchor-link" href="#row2"
              title="Permalink to mat4.get row2">#</a></h4>
<div class="doc">
<p>Returns row 2</p>
<pre class="source">
vec4 get row2 =&gt; getRow(2);
</pre>
</div>
</div>
<div class="method"><h4 id="row2=">
<button class="show-code">Code</button>
<strong>set row2</strong>(<a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#row2="
              title="Permalink to mat4.set row2">#</a></h4>
<div class="doc">
<p>Sets row 2 to 
<span class="param">arg</span></p>
<pre class="source">
set row2(vec4 arg) =&gt; setRow(2, arg);
</pre>
</div>
</div>
<div class="method"><h4 id="row3">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>get row3</strong> <a class="anchor-link" href="#row3"
              title="Permalink to mat4.get row3">#</a></h4>
<div class="doc">
<p>Returns row 3</p>
<pre class="source">
vec4 get row3 =&gt; getRow(3);
</pre>
</div>
</div>
<div class="method"><h4 id="row3=">
<button class="show-code">Code</button>
<strong>set row3</strong>(<a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#row3="
              title="Permalink to mat4.set row3">#</a></h4>
<div class="doc">
<p>Sets row 3 to 
<span class="param">arg</span></p>
<pre class="source">
set row3(vec4 arg) =&gt; setRow(3, arg);
</pre>
</div>
</div>
<div class="field"><h4 id="rows">
<button class="show-code">Code</button>
final int         <strong>rows</strong> <a class="anchor-link"
            href="#rows"
            title="Permalink to mat4.rows">#</a>
        </h4>
        <div class="doc">
<p>Returns the number of rows in the matrix.</p>
<pre class="source">
int get rows =&gt; 4;
</pre>
</div>
</div>
<div class="field"><h4 id="up">
<button class="show-code">Code</button>
final <a href="../vector_math/vec3.html">vec3</a>         <strong>up</strong> <a class="anchor-link"
            href="#up"
            title="Permalink to mat4.up">#</a>
        </h4>
        <div class="doc">
<pre class="source">
vec3 get up {
 vec3 f = new vec3.zero();
 f.x = col1.x;
 f.y = col1.y;
 f.z = col1.z;
 return f;
}
</pre>
</div>
</div>
</div>
<div>
<h3>Operators</h3>
<div class="method"><h4 id="[]">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>operator []</strong>(int column) <a class="anchor-link" href="#[]"
              title="Permalink to mat4.operator []">#</a></h4>
<div class="doc">
<p>Gets the 
<span class="param">column</span> of the matrix</p>
<pre class="source">
vec4 operator[](int column) {
 assert(column &gt;= 0 &amp;&amp; column &lt; 4);
 switch (column) {
   case 0: return col0;
   case 1: return col1;
   case 2: return col2;
   case 3: return col3;
 }
 throw new ArgumentError(column);
}
</pre>
</div>
</div>
<div class="method"><h4 id="[]=">
<button class="show-code">Code</button>
void <strong>operator []=</strong>(int column, <a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#[]="
              title="Permalink to mat4.operator []=">#</a></h4>
<div class="doc">
<p>Assigns the 
<span class="param">column</span> of the matrix 
<span class="param">arg</span></p>
<pre class="source">
void operator[]=(int column, vec4 arg) {
 assert(column &gt;= 0 &amp;&amp; column &lt; 4);
 switch (column) {
   case 0: col0 = arg; break;
   case 1: col1 = arg; break;
   case 2: col2 = arg; break;
   case 3: col3 = arg; break;
 }
 throw new ArgumentError(column);
}
</pre>
</div>
</div>
<div class="method"><h4 id="+">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>operator +</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#+"
              title="Permalink to mat4.operator +">#</a></h4>
<div class="doc">
<p>Returns new matrix after component wise <code>this</code> + 
<span class="param">arg</span></p>
<pre class="source">
mat4 operator+(mat4 arg) {
 mat4 r = new mat4.zero();
 r.col0.x = col0.x + arg.col0.x;
 r.col0.y = col0.y + arg.col0.y;
 r.col0.z = col0.z + arg.col0.z;
 r.col0.w = col0.w + arg.col0.w;
 r.col1.x = col1.x + arg.col1.x;
 r.col1.y = col1.y + arg.col1.y;
 r.col1.z = col1.z + arg.col1.z;
 r.col1.w = col1.w + arg.col1.w;
 r.col2.x = col2.x + arg.col2.x;
 r.col2.y = col2.y + arg.col2.y;
 r.col2.z = col2.z + arg.col2.z;
 r.col2.w = col2.w + arg.col2.w;
 r.col3.x = col3.x + arg.col3.x;
 r.col3.y = col3.y + arg.col3.y;
 r.col3.z = col3.z + arg.col3.z;
 r.col3.w = col3.w + arg.col3.w;
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="unary-">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>operator -</strong>() <a class="anchor-link" href="#unary-"
              title="Permalink to mat4.operator -">#</a></h4>
<div class="doc">
<p>Returns new matrix -this</p>
<pre class="source">
mat4 operator-() {
 mat4 r = new mat4.zero();
 r[0] = -this[0];
 r[1] = -this[1];
 r[2] = -this[2];
 r[3] = -this[3];
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="-">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>operator -</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#-"
              title="Permalink to mat4.operator -">#</a></h4>
<div class="doc">
<p>Returns new matrix after component wise <code>this</code> - 
<span class="param">arg</span></p>
<pre class="source">
mat4 operator-(mat4 arg) {
 mat4 r = new mat4.zero();
 r.col0.x = col0.x - arg.col0.x;
 r.col0.y = col0.y - arg.col0.y;
 r.col0.z = col0.z - arg.col0.z;
 r.col0.w = col0.w - arg.col0.w;
 r.col1.x = col1.x - arg.col1.x;
 r.col1.y = col1.y - arg.col1.y;
 r.col1.z = col1.z - arg.col1.z;
 r.col1.w = col1.w - arg.col1.w;
 r.col2.x = col2.x - arg.col2.x;
 r.col2.y = col2.y - arg.col2.y;
 r.col2.z = col2.z - arg.col2.z;
 r.col2.w = col2.w - arg.col2.w;
 r.col3.x = col3.x - arg.col3.x;
 r.col3.y = col3.y - arg.col3.y;
 r.col3.z = col3.z - arg.col3.z;
 r.col3.w = col3.w - arg.col3.w;
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="*">
<button class="show-code">Code</button>
<strong>operator *</strong>(arg) <a class="anchor-link" href="#*"
              title="Permalink to mat4.operator *">#</a></h4>
<div class="doc">
<p>Returns a new vector or matrix by multiplying <code>this</code> with 
<span class="param">arg</span>.</p>
<pre class="source">
dynamic operator*(dynamic arg) {
 if (arg is num) {
   mat4 r = new mat4.zero();
   r.col0.x = col0.x * arg;
   r.col0.y = col0.y * arg;
   r.col0.z = col0.z * arg;
   r.col0.w = col0.w * arg;
   r.col1.x = col1.x * arg;
   r.col1.y = col1.y * arg;
   r.col1.z = col1.z * arg;
   r.col1.w = col1.w * arg;
   r.col2.x = col2.x * arg;
   r.col2.y = col2.y * arg;
   r.col2.z = col2.z * arg;
   r.col2.w = col2.w * arg;
   r.col3.x = col3.x * arg;
   r.col3.y = col3.y * arg;
   r.col3.z = col3.z * arg;
   r.col3.w = col3.w * arg;
   return r;
 }
 if (arg is vec4) {
   vec4 r = new vec4.zero();
   r.x =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + (this.col3.x * arg.w);
   r.y =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + (this.col3.y * arg.w);
   r.z =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + (this.col3.z * arg.w);
   r.w =  (this.col0.w * arg.x) + (this.col1.w * arg.y) + (this.col2.w * arg.z) + (this.col3.w * arg.w);
   return r;
 }
 if (arg is vec3) {
   vec3 r = new vec3.zero();
   r.x =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + col3.x;
   r.y =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + col3.y;
   r.z =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + col3.z;
   return r;
 }
 if (4 == arg.rows) {
   dynamic r = null;
   if (arg.cols == 4) {
     r = new mat4.zero();
     r.col0.x =  (this.col0.x * arg.col0.x) + (this.col1.x * arg.col0.y) + (this.col2.x * arg.col0.z) + (this.col3.x * arg.col0.w);
     r.col1.x =  (this.col0.x * arg.col1.x) + (this.col1.x * arg.col1.y) + (this.col2.x * arg.col1.z) + (this.col3.x * arg.col1.w);
     r.col2.x =  (this.col0.x * arg.col2.x) + (this.col1.x * arg.col2.y) + (this.col2.x * arg.col2.z) + (this.col3.x * arg.col2.w);
     r.col3.x =  (this.col0.x * arg.col3.x) + (this.col1.x * arg.col3.y) + (this.col2.x * arg.col3.z) + (this.col3.x * arg.col3.w);
     r.col0.y =  (this.col0.y * arg.col0.x) + (this.col1.y * arg.col0.y) + (this.col2.y * arg.col0.z) + (this.col3.y * arg.col0.w);
     r.col1.y =  (this.col0.y * arg.col1.x) + (this.col1.y * arg.col1.y) + (this.col2.y * arg.col1.z) + (this.col3.y * arg.col1.w);
     r.col2.y =  (this.col0.y * arg.col2.x) + (this.col1.y * arg.col2.y) + (this.col2.y * arg.col2.z) + (this.col3.y * arg.col2.w);
     r.col3.y =  (this.col0.y * arg.col3.x) + (this.col1.y * arg.col3.y) + (this.col2.y * arg.col3.z) + (this.col3.y * arg.col3.w);
     r.col0.z =  (this.col0.z * arg.col0.x) + (this.col1.z * arg.col0.y) + (this.col2.z * arg.col0.z) + (this.col3.z * arg.col0.w);
     r.col1.z =  (this.col0.z * arg.col1.x) + (this.col1.z * arg.col1.y) + (this.col2.z * arg.col1.z) + (this.col3.z * arg.col1.w);
     r.col2.z =  (this.col0.z * arg.col2.x) + (this.col1.z * arg.col2.y) + (this.col2.z * arg.col2.z) + (this.col3.z * arg.col2.w);
     r.col3.z =  (this.col0.z * arg.col3.x) + (this.col1.z * arg.col3.y) + (this.col2.z * arg.col3.z) + (this.col3.z * arg.col3.w);
     r.col0.w =  (this.col0.w * arg.col0.x) + (this.col1.w * arg.col0.y) + (this.col2.w * arg.col0.z) + (this.col3.w * arg.col0.w);
     r.col1.w =  (this.col0.w * arg.col1.x) + (this.col1.w * arg.col1.y) + (this.col2.w * arg.col1.z) + (this.col3.w * arg.col1.w);
     r.col2.w =  (this.col0.w * arg.col2.x) + (this.col1.w * arg.col2.y) + (this.col2.w * arg.col2.z) + (this.col3.w * arg.col2.w);
     r.col3.w =  (this.col0.w * arg.col3.x) + (this.col1.w * arg.col3.y) + (this.col2.w * arg.col3.z) + (this.col3.w * arg.col3.w);
     return r;
   }
   return r;
 }
 throw new ArgumentError(arg);
}
</pre>
</div>
</div>
</div>
<div>
<h3>Methods</h3>
<div class="method"><h4 id="absolute">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>absolute</strong>() <a class="anchor-link" href="#absolute"
              title="Permalink to mat4.absolute">#</a></h4>
<div class="doc">
<p>Returns the component wise absolute value of this.</p>
<pre class="source">
mat4 absolute() {
 mat4 r = new mat4.zero();
 r.col0.x = col0.x.abs();
 r.col0.y = col0.y.abs();
 r.col0.z = col0.z.abs();
 r.col0.w = col0.w.abs();
 r.col1.x = col1.x.abs();
 r.col1.y = col1.y.abs();
 r.col1.z = col1.z.abs();
 r.col1.w = col1.w.abs();
 r.col2.x = col2.x.abs();
 r.col2.y = col2.y.abs();
 r.col2.z = col2.z.abs();
 r.col2.w = col2.w.abs();
 r.col3.x = col3.x.abs();
 r.col3.y = col3.y.abs();
 r.col3.z = col3.z.abs();
 r.col3.w = col3.w.abs();
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="absoluteError">
<button class="show-code">Code</button>
double <strong>absoluteError</strong>(<a href="../vector_math/mat4.html">mat4</a> correct) <a class="anchor-link" href="#absoluteError"
              title="Permalink to mat4.absoluteError">#</a></h4>
<div class="doc">
<p>Returns absolute error between <code>this</code> and 
<span class="param">correct</span></p>
<pre class="source">
double absoluteError(mat4 correct) {
 double this_norm = infinityNorm();
 double correct_norm = correct.infinityNorm();
 double diff_norm = (this_norm - correct_norm).abs();
 return diff_norm;
}
</pre>
</div>
</div>
<div class="method"><h4 id="absoluteRotate">
<button class="show-code">Code</button>
<a href="../vector_math/vec3.html">vec3</a> <strong>absoluteRotate</strong>(<a href="../vector_math/vec3.html">vec3</a> arg) <a class="anchor-link" href="#absoluteRotate"
              title="Permalink to mat4.absoluteRotate">#</a></h4>
<div class="doc">
<p>Rotates 
<span class="param">arg</span> by the absolute rotation of <code>this</code>
Returns 
<span class="param">arg</span>.
Primarily used by AABB transformation code.</p>
<pre class="source">
vec3 absoluteRotate(vec3 arg) {
 double m00 = col0.x.abs();
 double m01 = col1.x.abs();
 double m02 = col2.x.abs();
 double m10 = col0.y.abs();
 double m11 = col1.y.abs();
 double m12 = col2.y.abs();
 double m20 = col0.z.abs();
 double m21 = col1.z.abs();
 double m22 = col2.z.abs();
 double x = arg.x;
 double y = arg.y;
 double z = arg.z;
 arg.x = x * m00 + y * m01 + z * m02 + 0.0 * 0.0;
 arg.y = x * m10 + y * m11 + z * m12 + 0.0 * 0.0;
 arg.z = x * m20 + y * m21 + z * m22 + 0.0 * 0.0;
 return arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="add">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>add</strong>(<a href="../vector_math/mat4.html">mat4</a> o) <a class="anchor-link" href="#add"
              title="Permalink to mat4.add">#</a></h4>
<div class="doc">
<pre class="source">
mat4 add(mat4 o) {
 col0.x = col0.x + o.col0.x;
 col0.y = col0.y + o.col0.y;
 col0.z = col0.z + o.col0.z;
 col0.w = col0.w + o.col0.w;
 col1.x = col1.x + o.col1.x;
 col1.y = col1.y + o.col1.y;
 col1.z = col1.z + o.col1.z;
 col1.w = col1.w + o.col1.w;
 col2.x = col2.x + o.col2.x;
 col2.y = col2.y + o.col2.y;
 col2.z = col2.z + o.col2.z;
 col2.w = col2.w + o.col2.w;
 col3.x = col3.x + o.col3.x;
 col3.y = col3.y + o.col3.y;
 col3.z = col3.z + o.col3.z;
 col3.w = col3.w + o.col3.w;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="clone">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>clone</strong>() <a class="anchor-link" href="#clone"
              title="Permalink to mat4.clone">#</a></h4>
<div class="doc">
<pre class="source">
mat4 clone() {
 return new mat4.copy(this);
}
</pre>
</div>
</div>
<div class="method"><h4 id="copyFrom">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>copyFrom</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#copyFrom"
              title="Permalink to mat4.copyFrom">#</a></h4>
<div class="doc">
<pre class="source">
mat4 copyFrom(mat4 arg) {
 col0.x = arg.col0.x;
 col0.y = arg.col0.y;
 col0.z = arg.col0.z;
 col0.w = arg.col0.w;
 col1.x = arg.col1.x;
 col1.y = arg.col1.y;
 col1.z = arg.col1.z;
 col1.w = arg.col1.w;
 col2.x = arg.col2.x;
 col2.y = arg.col2.y;
 col2.z = arg.col2.z;
 col2.w = arg.col2.w;
 col3.x = arg.col3.x;
 col3.y = arg.col3.y;
 col3.z = arg.col3.z;
 col3.w = arg.col3.w;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="copyFromArray">
<button class="show-code">Code</button>
void <strong>copyFromArray</strong>(List&lt;num&gt; array, [int offset = 0]) <a class="anchor-link" href="#copyFromArray"
              title="Permalink to mat4.copyFromArray">#</a></h4>
<div class="doc">
<p>Copies elements from 
<span class="param">array</span> into <code>this</code> starting at 
<span class="param">offset</span>.</p>
<pre class="source">
void copyFromArray(List&lt;num&gt; array, [int offset=0]) {
 int i = offset;
 col0.x = array[i].toDouble();
 i++;
 col0.y = array[i].toDouble();
 i++;
 col0.z = array[i].toDouble();
 i++;
 col0.w = array[i].toDouble();
 i++;
 col1.x = array[i].toDouble();
 i++;
 col1.y = array[i].toDouble();
 i++;
 col1.z = array[i].toDouble();
 i++;
 col1.w = array[i].toDouble();
 i++;
 col2.x = array[i].toDouble();
 i++;
 col2.y = array[i].toDouble();
 i++;
 col2.z = array[i].toDouble();
 i++;
 col2.w = array[i].toDouble();
 i++;
 col3.x = array[i].toDouble();
 i++;
 col3.y = array[i].toDouble();
 i++;
 col3.z = array[i].toDouble();
 i++;
 col3.w = array[i].toDouble();
 i++;
}
</pre>
</div>
</div>
<div class="method"><h4 id="copyInto">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>copyInto</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#copyInto"
              title="Permalink to mat4.copyInto">#</a></h4>
<div class="doc">
<pre class="source">
mat4 copyInto(mat4 arg) {
 arg.col0.x = col0.x;
 arg.col0.y = col0.y;
 arg.col0.z = col0.z;
 arg.col0.w = col0.w;
 arg.col1.x = col1.x;
 arg.col1.y = col1.y;
 arg.col1.z = col1.z;
 arg.col1.w = col1.w;
 arg.col2.x = col2.x;
 arg.col2.y = col2.y;
 arg.col2.z = col2.z;
 arg.col2.w = col2.w;
 arg.col3.x = col3.x;
 arg.col3.y = col3.y;
 arg.col3.z = col3.z;
 arg.col3.w = col3.w;
 return arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="copyIntoArray">
<button class="show-code">Code</button>
void <strong>copyIntoArray</strong>(List&lt;num&gt; array, [int offset = 0]) <a class="anchor-link" href="#copyIntoArray"
              title="Permalink to mat4.copyIntoArray">#</a></h4>
<div class="doc">
<p>Copies <code>this</code> into 
<span class="param">array</span> starting at 
<span class="param">offset</span>.</p>
<pre class="source">
void copyIntoArray(List&lt;num&gt; array, [int offset=0]) {
 int i = offset;
 array[i] = col0.x;
 i++;
 array[i] = col0.y;
 i++;
 array[i] = col0.z;
 i++;
 array[i] = col0.w;
 i++;
 array[i] = col1.x;
 i++;
 array[i] = col1.y;
 i++;
 array[i] = col1.z;
 i++;
 array[i] = col1.w;
 i++;
 array[i] = col2.x;
 i++;
 array[i] = col2.y;
 i++;
 array[i] = col2.z;
 i++;
 array[i] = col2.w;
 i++;
 array[i] = col3.x;
 i++;
 array[i] = col3.y;
 i++;
 array[i] = col3.z;
 i++;
 array[i] = col3.w;
 i++;
}
</pre>
</div>
</div>
<div class="method"><h4 id="determinant">
<button class="show-code">Code</button>
double <strong>determinant</strong>() <a class="anchor-link" href="#determinant"
              title="Permalink to mat4.determinant">#</a></h4>
<div class="doc">
<p>Returns the determinant of this matrix.</p>
<pre class="source">
double determinant() {
 double det2_01_01 = col0.x * col1.y - col0.y * col1.x;
 double det2_01_02 = col0.x * col1.z - col0.z * col1.x;
 double det2_01_03 = col0.x * col1.w - col0.w * col1.x;
 double det2_01_12 = col0.y * col1.z - col0.z * col1.y;
 double det2_01_13 = col0.y * col1.w - col0.w * col1.y;
 double det2_01_23 = col0.z * col1.w - col0.w * col1.z;
 double det3_201_012 = col2.x * det2_01_12 - col2.y * det2_01_02 + col2.z * det2_01_01;
 double det3_201_013 = col2.x * det2_01_13 - col2.y * det2_01_03 + col2.w * det2_01_01;
 double det3_201_023 = col2.x * det2_01_23 - col2.z * det2_01_03 + col2.w * det2_01_02;
 double det3_201_123 = col2.y * det2_01_23 - col2.z * det2_01_13 + col2.w * det2_01_12;
 return ( - det3_201_123 * col3.x + det3_201_023 * col3.y - det3_201_013 * col3.z + det3_201_012 * col3.w);
}
</pre>
</div>
</div>
<div class="method"><h4 id="getColumn">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>getColumn</strong>(int column) <a class="anchor-link" href="#getColumn"
              title="Permalink to mat4.getColumn">#</a></h4>
<div class="doc">
<p>Gets the 
<span class="param">column</span> of the matrix</p>
<pre class="source">
vec4 getColumn(int column) {
 assert(column &gt;= 0 &amp;&amp; column &lt; 4);
 return new vec4.copy(this[column]);
}
</pre>
</div>
</div>
<div class="method"><h4 id="getRotation">
<button class="show-code">Code</button>
<a href="../vector_math/mat3.html">mat3</a> <strong>getRotation</strong>() <a class="anchor-link" href="#getRotation"
              title="Permalink to mat4.getRotation">#</a></h4>
<div class="doc">
<p>Returns the rotation matrix from this homogeneous transformation matrix.</p>
<pre class="source">
mat3 getRotation() {
 mat3 r = new mat3.zero();
 r.col0 = new vec3.raw(this.col0.x,this.col0.y,this.col0.z);
 r.col1 = new vec3.raw(this.col1.x,this.col1.y,this.col1.z);
 r.col2 = new vec3.raw(this.col2.x,this.col2.y,this.col2.z);
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="getRow">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>getRow</strong>(int row) <a class="anchor-link" href="#getRow"
              title="Permalink to mat4.getRow">#</a></h4>
<div class="doc">
<p>Gets the 
<span class="param">row</span> of the matrix</p>
<pre class="source">
vec4 getRow(int row) {
 assert(row &gt;= 0 &amp;&amp; row &lt; 4);
 vec4 r = new vec4.zero();
 r.x = col0[row];
 r.y = col1[row];
 r.z = col2[row];
 r.w = col3[row];
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="getTranslation">
<button class="show-code">Code</button>
<a href="../vector_math/vec3.html">vec3</a> <strong>getTranslation</strong>() <a class="anchor-link" href="#getTranslation"
              title="Permalink to mat4.getTranslation">#</a></h4>
<div class="doc">
<p>Returns the translation vector from this homogeneous transformation matrix.</p>
<pre class="source">
vec3 getTranslation() {
 return new vec3.raw(col3.x, col3.y, col3.z);
}
</pre>
</div>
</div>
<div class="method"><h4 id="infinityNorm">
<button class="show-code">Code</button>
double <strong>infinityNorm</strong>() <a class="anchor-link" href="#infinityNorm"
              title="Permalink to mat4.infinityNorm">#</a></h4>
<div class="doc">
<p>Returns infinity norm of the matrix. Used for numerical analysis.</p>
<pre class="source">
double infinityNorm() {
 double norm = 0.0;
 {
   double row_norm = 0.0;
   row_norm += this[0][0].abs();
   row_norm += this[0][1].abs();
   row_norm += this[0][2].abs();
   row_norm += this[0][3].abs();
   norm = row_norm &gt; norm ? row_norm : norm;
 }
 {
   double row_norm = 0.0;
   row_norm += this[1][0].abs();
   row_norm += this[1][1].abs();
   row_norm += this[1][2].abs();
   row_norm += this[1][3].abs();
   norm = row_norm &gt; norm ? row_norm : norm;
 }
 {
   double row_norm = 0.0;
   row_norm += this[2][0].abs();
   row_norm += this[2][1].abs();
   row_norm += this[2][2].abs();
   row_norm += this[2][3].abs();
   norm = row_norm &gt; norm ? row_norm : norm;
 }
 {
   double row_norm = 0.0;
   row_norm += this[3][0].abs();
   row_norm += this[3][1].abs();
   row_norm += this[3][2].abs();
   row_norm += this[3][3].abs();
   norm = row_norm &gt; norm ? row_norm : norm;
 }
 return norm;
}
</pre>
</div>
</div>
<div class="method"><h4 id="invert">
<button class="show-code">Code</button>
double <strong>invert</strong>() <a class="anchor-link" href="#invert"
              title="Permalink to mat4.invert">#</a></h4>
<div class="doc">
<pre class="source">
double invert() {
 double a00 = col0.x;
 double a01 = col0.y;
 double a02 = col0.z;
 double a03 = col0.w;
 double a10 = col1.x;
 double a11 = col1.y;
 double a12 = col1.z;
 double a13 = col1.w;
 double a20 = col2.x;
 double a21 = col2.y;
 double a22 = col2.z;
 double a23 = col2.w;
 double a30 = col3.x;
 double a31 = col3.y;
 double a32 = col3.z;
 double a33 = col3.w;
 var b00 = a00 * a11 - a01 * a10;
 var b01 = a00 * a12 - a02 * a10;
 var b02 = a00 * a13 - a03 * a10;
 var b03 = a01 * a12 - a02 * a11;
 var b04 = a01 * a13 - a03 * a11;
 var b05 = a02 * a13 - a03 * a12;
 var b06 = a20 * a31 - a21 * a30;
 var b07 = a20 * a32 - a22 * a30;
 var b08 = a20 * a33 - a23 * a30;
 var b09 = a21 * a32 - a22 * a31;
 var b10 = a21 * a33 - a23 * a31;
 var b11 = a22 * a33 - a23 * a32;
 var det = (b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06);
 if (det == 0.0) { return det; }
 var invDet = 1.0 / det;
 col0.x = (a11 * b11 - a12 * b10 + a13 * b09) * invDet;
 col0.y = (-a01 * b11 + a02 * b10 - a03 * b09) * invDet;
 col0.z = (a31 * b05 - a32 * b04 + a33 * b03) * invDet;
 col0.w = (-a21 * b05 + a22 * b04 - a23 * b03) * invDet;
 col1.x = (-a10 * b11 + a12 * b08 - a13 * b07) * invDet;
 col1.y = (a00 * b11 - a02 * b08 + a03 * b07) * invDet;
 col1.z = (-a30 * b05 + a32 * b02 - a33 * b01) * invDet;
 col1.w = (a20 * b05 - a22 * b02 + a23 * b01) * invDet;
 col2.x = (a10 * b10 - a11 * b08 + a13 * b06) * invDet;
 col2.y = (-a00 * b10 + a01 * b08 - a03 * b06) * invDet;
 col2.z = (a30 * b04 - a31 * b02 + a33 * b00) * invDet;
 col2.w = (-a20 * b04 + a21 * b02 - a23 * b00) * invDet;
 col3.x = (-a10 * b09 + a11 * b07 - a12 * b06) * invDet;
 col3.y = (a00 * b09 - a01 * b07 + a02 * b06) * invDet;
 col3.z = (-a30 * b03 + a31 * b01 - a32 * b00) * invDet;
 col3.w = (a20 * b03 - a21 * b01 + a22 * b00) * invDet;
 return det;
}
</pre>
</div>
</div>
<div class="method"><h4 id="invertRotation">
<button class="show-code">Code</button>
double <strong>invertRotation</strong>() <a class="anchor-link" href="#invertRotation"
              title="Permalink to mat4.invertRotation">#</a></h4>
<div class="doc">
<pre class="source">
double invertRotation() {
 double det = determinant();
 if (det == 0.0) {
   return 0.0;
 }
 double invDet = 1.0 / det;
 vec4 i = new vec4.zero();
 vec4 j = new vec4.zero();
 vec4 k = new vec4.zero();
 i.x = invDet * (col1.y * col2.z - col1.z * col2.y);
 i.y = invDet * (col0.z * col2.y - col0.y * col2.z);
 i.z = invDet * (col0.y * col1.z - col0.z * col1.y);
 j.x = invDet * (col1.z * col2.x - col1.x * col2.z);
 j.y = invDet * (col0.x * col2.z - col0.z * col2.x);
 j.z = invDet * (col0.z * col1.x - col0.x * col1.z);
 k.x = invDet * (col1.x * col2.y - col1.y * col2.x);
 k.y = invDet * (col0.y * col2.x - col0.x * col2.y);
 k.z = invDet * (col0.x * col1.y - col0.y * col1.x);
 col0 = i;
 col1 = j;
 col2 = k;
 return det;
}
</pre>
</div>
</div>
<div class="method"><h4 id="multiply">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>multiply</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#multiply"
              title="Permalink to mat4.multiply">#</a></h4>
<div class="doc">
<pre class="source">
mat4 multiply(mat4 arg) {
 final double m00 = col0.x;
 final double m01 = col1.x;
 final double m02 = col2.x;
 final double m03 = col3.x;
 final double m10 = col0.y;
 final double m11 = col1.y;
 final double m12 = col2.y;
 final double m13 = col3.y;
 final double m20 = col0.z;
 final double m21 = col1.z;
 final double m22 = col2.z;
 final double m23 = col3.z;
 final double m30 = col0.w;
 final double m31 = col1.w;
 final double m32 = col2.w;
 final double m33 = col3.w;
 final double n00 = arg.col0.x;
 final double n01 = arg.col1.x;
 final double n02 = arg.col2.x;
 final double n03 = arg.col3.x;
 final double n10 = arg.col0.y;
 final double n11 = arg.col1.y;
 final double n12 = arg.col2.y;
 final double n13 = arg.col3.y;
 final double n20 = arg.col0.z;
 final double n21 = arg.col1.z;
 final double n22 = arg.col2.z;
 final double n23 = arg.col3.z;
 final double n30 = arg.col0.w;
 final double n31 = arg.col1.w;
 final double n32 = arg.col2.w;
 final double n33 = arg.col3.w;
 col0.x =  (m00 * n00) + (m01 * n10) + (m02 * n20) + (m03 * n30);
 col1.x =  (m00 * n01) + (m01 * n11) + (m02 * n21) + (m03 * n31);
 col2.x =  (m00 * n02) + (m01 * n12) + (m02 * n22) + (m03 * n32);
 col3.x =  (m00 * n03) + (m01 * n13) + (m02 * n23) + (m03 * n33);
 col0.y =  (m10 * n00) + (m11 * n10) + (m12 * n20) + (m13 * n30);
 col1.y =  (m10 * n01) + (m11 * n11) + (m12 * n21) + (m13 * n31);
 col2.y =  (m10 * n02) + (m11 * n12) + (m12 * n22) + (m13 * n32);
 col3.y =  (m10 * n03) + (m11 * n13) + (m12 * n23) + (m13 * n33);
 col0.z =  (m20 * n00) + (m21 * n10) + (m22 * n20) + (m23 * n30);
 col1.z =  (m20 * n01) + (m21 * n11) + (m22 * n21) + (m23 * n31);
 col2.z =  (m20 * n02) + (m21 * n12) + (m22 * n22) + (m23 * n32);
 col3.z =  (m20 * n03) + (m21 * n13) + (m22 * n23) + (m23 * n33);
 col0.w =  (m30 * n00) + (m31 * n10) + (m32 * n20) + (m33 * n30);
 col1.w =  (m30 * n01) + (m31 * n11) + (m32 * n21) + (m33 * n31);
 col2.w =  (m30 * n02) + (m31 * n12) + (m32 * n22) + (m33 * n32);
 col3.w =  (m30 * n03) + (m31 * n13) + (m32 * n23) + (m33 * n33);
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="multiplyTranspose">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>multiplyTranspose</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#multiplyTranspose"
              title="Permalink to mat4.multiplyTranspose">#</a></h4>
<div class="doc">
<pre class="source">
mat4 multiplyTranspose(mat4 arg) {
 double m00 = col0.x;
 double m01 = col1.x;
 double m02 = col2.x;
 double m03 = col3.x;
 double m10 = col0.y;
 double m11 = col1.y;
 double m12 = col2.y;
 double m13 = col3.y;
 double m20 = col0.z;
 double m21 = col1.z;
 double m22 = col2.z;
 double m23 = col3.z;
 double m30 = col0.w;
 double m31 = col1.w;
 double m32 = col2.w;
 double m33 = col3.w;
 col0.x =  (m00 * arg.col0.x) + (m01 * arg.col1.x) + (m02 * arg.col2.x) + (m03 * arg.col3.x);
 col1.x =  (m00 * arg.col0.y) + (m01 * arg.col1.y) + (m02 * arg.col2.y) + (m03 * arg.col3.y);
 col2.x =  (m00 * arg.col0.z) + (m01 * arg.col1.z) + (m02 * arg.col2.z) + (m03 * arg.col3.z);
 col3.x =  (m00 * arg.col0.w) + (m01 * arg.col1.w) + (m02 * arg.col2.w) + (m03 * arg.col3.w);
 col0.y =  (m10 * arg.col0.x) + (m11 * arg.col1.x) + (m12 * arg.col2.x) + (m13 * arg.col3.x);
 col1.y =  (m10 * arg.col0.y) + (m11 * arg.col1.y) + (m12 * arg.col2.y) + (m13 * arg.col3.y);
 col2.y =  (m10 * arg.col0.z) + (m11 * arg.col1.z) + (m12 * arg.col2.z) + (m13 * arg.col3.z);
 col3.y =  (m10 * arg.col0.w) + (m11 * arg.col1.w) + (m12 * arg.col2.w) + (m13 * arg.col3.w);
 col0.z =  (m20 * arg.col0.x) + (m21 * arg.col1.x) + (m22 * arg.col2.x) + (m23 * arg.col3.x);
 col1.z =  (m20 * arg.col0.y) + (m21 * arg.col1.y) + (m22 * arg.col2.y) + (m23 * arg.col3.y);
 col2.z =  (m20 * arg.col0.z) + (m21 * arg.col1.z) + (m22 * arg.col2.z) + (m23 * arg.col3.z);
 col3.z =  (m20 * arg.col0.w) + (m21 * arg.col1.w) + (m22 * arg.col2.w) + (m23 * arg.col3.w);
 col0.w =  (m30 * arg.col0.x) + (m31 * arg.col1.x) + (m32 * arg.col2.x) + (m33 * arg.col3.x);
 col1.w =  (m30 * arg.col0.y) + (m31 * arg.col1.y) + (m32 * arg.col2.y) + (m33 * arg.col3.y);
 col2.w =  (m30 * arg.col0.z) + (m31 * arg.col1.z) + (m32 * arg.col2.z) + (m33 * arg.col3.z);
 col3.w =  (m30 * arg.col0.w) + (m31 * arg.col1.w) + (m32 * arg.col2.w) + (m33 * arg.col3.w);
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="negate">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>negate</strong>() <a class="anchor-link" href="#negate"
              title="Permalink to mat4.negate">#</a></h4>
<div class="doc">
<pre class="source">
mat4 negate() {
 col0.x = -col0.x;
 col0.y = -col0.y;
 col0.z = -col0.z;
 col0.w = -col0.w;
 col1.x = -col1.x;
 col1.y = -col1.y;
 col1.z = -col1.z;
 col1.w = -col1.w;
 col2.x = -col2.x;
 col2.y = -col2.y;
 col2.z = -col2.z;
 col2.w = -col2.w;
 col3.x = -col3.x;
 col3.y = -col3.y;
 col3.z = -col3.z;
 col3.w = -col3.w;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="relativeError">
<button class="show-code">Code</button>
double <strong>relativeError</strong>(<a href="../vector_math/mat4.html">mat4</a> correct) <a class="anchor-link" href="#relativeError"
              title="Permalink to mat4.relativeError">#</a></h4>
<div class="doc">
<p>Returns relative error between <code>this</code> and 
<span class="param">correct</span></p>
<pre class="source">
double relativeError(mat4 correct) {
 mat4 diff = correct - this;
 double correct_norm = correct.infinityNorm();
 double diff_norm = diff.infinityNorm();
 return diff_norm/correct_norm;
}
</pre>
</div>
</div>
<div class="method"><h4 id="rotate">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>rotate</strong>(<a href="../vector_math/vec3.html">vec3</a> axis, num angle_) <a class="anchor-link" href="#rotate"
              title="Permalink to mat4.rotate">#</a></h4>
<div class="doc">
<p>Rotate this <code>angle</code> radians around 
<span class="param">axis</span></p>
<pre class="source">
mat4 rotate(vec3 axis, num angle_) {
 var len = axis.length;
 double angle = angle_.toDouble();
 var x = axis.x/len;
 var y = axis.y/len;
 var z = axis.z/len;
 var c = cos(angle);
 var s = sin(angle);
 var C = 1.0 - c;
 var m11 = x * x * C + c;
 var m12 = x * y * C - z * s;
 var m13 = x * z * C + y * s;
 var m21 = y * x * C + z * s;
 var m22 = y * y * C + c;
 var m23 = y * z * C - x * s;
 var m31 = z * x * C - y * s;
 var m32 = z * y * C + x * s;
 var m33 = z * z * C + c;
 var t1 = col0.x * m11 + col1.x * m21 + col2.x * m31 + col3.x * 0.0;
 var t2 = col0.y * m11 + col1.y * m21 + col2.y * m31 + col3.y * 0.0;
 var t3 = col0.z * m11 + col1.z * m21 + col2.z * m31 + col3.z * 0.0;
 var t4 = col0.w * m11 + col1.w * m21 + col2.w * m31 + col3.w * 0.0;
 var t5 = col0.x * m12 + col1.x * m22 + col2.x * m32 + col3.x * 0.0;
 var t6 = col0.y * m12 + col1.y * m22 + col2.y * m32 + col3.y * 0.0;
 var t7 = col0.z * m12 + col1.z * m22 + col2.z * m32 + col3.z * 0.0;
 var t8 = col0.w * m12 + col1.w * m22 + col2.w * m32 + col3.w * 0.0;
 var t9 = col0.x * m13 + col1.x * m23 + col2.x * m33 + col3.x * 0.0;
 var t10 = col0.y * m13 + col1.y * m23 + col2.y * m33 + col3.y * 0.0;
 var t11 = col0.z * m13 + col1.z * m23 + col2.z * m33 + col3.z * 0.0;
 var t12 = col0.w * m13 + col1.w * m23 + col2.w * m33 + col3.w * 0.0;
 col0.x = t1;
 col0.y = t2;
 col0.z = t3;
 col0.w = t4;
 col1.x = t5;
 col1.y = t6;
 col1.z = t7;
 col1.w = t8;
 col2.x = t9;
 col2.y = t10;
 col2.z = t11;
 col2.w = t12;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="rotate3">
<button class="show-code">Code</button>
<a href="../vector_math/vec3.html">vec3</a> <strong>rotate3</strong>(<a href="../vector_math/vec3.html">vec3</a> arg) <a class="anchor-link" href="#rotate3"
              title="Permalink to mat4.rotate3">#</a></h4>
<div class="doc">
<pre class="source">
vec3 rotate3(vec3 arg) {
 double x_ =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z);
 double y_ =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z);
 double z_ =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z);
 arg.x = x_;
 arg.y = y_;
 arg.z = z_;
 return arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="rotated3">
<button class="show-code">Code</button>
<a href="../vector_math/vec3.html">vec3</a> <strong>rotated3</strong>(<a href="../vector_math/vec3.html">vec3</a> arg, [<a href="../vector_math/vec3.html">vec3</a> out = null]) <a class="anchor-link" href="#rotated3"
              title="Permalink to mat4.rotated3">#</a></h4>
<div class="doc">
<pre class="source">
vec3 rotated3(vec3 arg, [vec3 out=null]) {
 if (out == null) {
   out = new vec3.copy(arg);
 } else {
   out.copyFrom(arg);
 }
 return rotate3(out);
}
</pre>
</div>
</div>
<div class="method"><h4 id="rotateX">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>rotateX</strong>(num angle_) <a class="anchor-link" href="#rotateX"
              title="Permalink to mat4.rotateX">#</a></h4>
<div class="doc">
<p>Rotate this <code>angle</code> radians around X</p>
<pre class="source">
mat4 rotateX(num angle_) {
 double angle = angle_.toDouble();
 double cosAngle = cos(angle);
 double sinAngle = sin(angle);
 var t1 = col0.x * 0.0 + col1.x * cosAngle + col2.x * sinAngle + col3.x * 0.0;
 var t2 = col0.y * 0.0 + col1.y * cosAngle + col2.y * sinAngle + col3.y * 0.0;
 var t3 = col0.z * 0.0 + col1.z * cosAngle + col2.z * sinAngle + col3.z * 0.0;
 var t4 = col0.w * 0.0 + col1.w * cosAngle + col2.w * sinAngle + col3.w * 0.0;
 var t5 = col0.x * 0.0 + col1.x * -sinAngle + col2.x * cosAngle + col3.x * 0.0;
 var t6 = col0.y * 0.0 + col1.y * -sinAngle + col2.y * cosAngle + col3.y * 0.0;
 var t7 = col0.z * 0.0 + col1.z * -sinAngle + col2.z * cosAngle + col3.z * 0.0;
 var t8 = col0.w * 0.0 + col1.w * -sinAngle + col2.w * cosAngle + col3.w * 0.0;
 col1.x = t1;
 col1.y = t2;
 col1.z = t3;
 col1.w = t4;
 col2.x = t5;
 col2.y = t6;
 col2.z = t7;
 col2.w = t8;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="rotateY">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>rotateY</strong>(double angle) <a class="anchor-link" href="#rotateY"
              title="Permalink to mat4.rotateY">#</a></h4>
<div class="doc">
<p>Rotate this matrix 
<span class="param">angle</span> radians around Y</p>
<pre class="source">
mat4 rotateY(double angle) {
 double cosAngle = cos(angle);
 double sinAngle = sin(angle);
 var t1 = col0.x * cosAngle + col1.x * 0.0 + col2.x * sinAngle + col3.x * 0.0;
 var t2 = col0.y * cosAngle + col1.y * 0.0 + col2.y * sinAngle + col3.y * 0.0;
 var t3 = col0.z * cosAngle + col1.z * 0.0 + col2.z * sinAngle + col3.z * 0.0;
 var t4 = col0.w * cosAngle + col1.w * 0.0 + col2.w * sinAngle + col3.w * 0.0;
 var t5 = col0.x * -sinAngle + col1.x * 0.0 + col2.x * cosAngle + col3.x * 0.0;
 var t6 = col0.y * -sinAngle + col1.y * 0.0 + col2.y * cosAngle + col3.y * 0.0;
 var t7 = col0.z * -sinAngle + col1.z * 0.0 + col2.z * cosAngle + col3.z * 0.0;
 var t8 = col0.w * -sinAngle + col1.w * 0.0 + col2.w * cosAngle + col3.w * 0.0;
 col0.x = t1;
 col0.y = t2;
 col0.z = t3;
 col0.w = t4;
 col2.x = t5;
 col2.y = t6;
 col2.z = t7;
 col2.w = t8;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="rotateZ">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>rotateZ</strong>(double angle) <a class="anchor-link" href="#rotateZ"
              title="Permalink to mat4.rotateZ">#</a></h4>
<div class="doc">
<p>Rotate this matrix 
<span class="param">angle</span> radians around Z</p>
<pre class="source">
mat4 rotateZ(double angle) {
 double cosAngle = cos(angle);
 double sinAngle = sin(angle);
 var t1 = col0.x * cosAngle + col1.x * sinAngle + col2.x * 0.0 + col3.x * 0.0;
 var t2 = col0.y * cosAngle + col1.y * sinAngle + col2.y * 0.0 + col3.y * 0.0;
 var t3 = col0.z * cosAngle + col1.z * sinAngle + col2.z * 0.0 + col3.z * 0.0;
 var t4 = col0.w * cosAngle + col1.w * sinAngle + col2.w * 0.0 + col3.w * 0.0;
 var t5 = col0.x * -sinAngle + col1.x * cosAngle + col2.x * 0.0 + col3.x * 0.0;
 var t6 = col0.y * -sinAngle + col1.y * cosAngle + col2.y * 0.0 + col3.y * 0.0;
 var t7 = col0.z * -sinAngle + col1.z * cosAngle + col2.z * 0.0 + col3.z * 0.0;
 var t8 = col0.w * -sinAngle + col1.w * cosAngle + col2.w * 0.0 + col3.w * 0.0;
 col0.x = t1;
 col0.y = t2;
 col0.z = t3;
 col0.w = t4;
 col1.x = t5;
 col1.y = t6;
 col1.z = t7;
 col1.w = t8;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="scale">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>scale</strong>(x, [num y = null, num z = null]) <a class="anchor-link" href="#scale"
              title="Permalink to mat4.scale">#</a></h4>
<div class="doc">
<p>Scale this matrix by a <a class="crossref" href="../vector_math/vec3.html">vec3</a>, <a class="crossref" href="../vector_math/vec4.html">vec4</a>, or x,y,z</p>
<pre class="source">
mat4 scale(dynamic x, [num y = null, num z = null]) {
 double sx;
 double sy;
 double sz;
 double sw = x is vec4 ? x.w : 1.0;
 if (x is vec3 || x is vec4) {
   sx = x.x;
   sy = x.y;
   sz = x.z;
 } else {
   sx = x;
   sy = y == null ? x : y.toDouble();
   sz = z == null ? x : z.toDouble();
 }
 col0.x *= sx;
 col1.x *= sx;
 col2.x *= sx;
 col3.x *= sx;
 col0.y *= sy;
 col1.y *= sy;
 col2.y *= sy;
 col3.y *= sy;
 col0.z *= sz;
 col1.z *= sz;
 col2.z *= sz;
 col3.z *= sz;
 col0.w *= sw;
 col1.w *= sw;
 col2.w *= sw;
 col3.w *= sw;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="scaleAdjoint">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>scaleAdjoint</strong>(num scale) <a class="anchor-link" href="#scaleAdjoint"
              title="Permalink to mat4.scaleAdjoint">#</a></h4>
<div class="doc">
<p>Converts into Adjugate matrix and scales by 
<span class="param">scale</span></p>
<pre class="source">
mat4 scaleAdjoint(num scale) {
 double scale_ = scale.toDouble();
 // Adapted from code by Richard Carling.
 double a1 = col0.x;
 double b1 = col1.x;
 double c1 = col2.x;
 double d1 = col3.x;
 double a2 = col0.y;
 double b2 = col1.y;
 double c2 = col2.y;
 double d2 = col3.y;
 double a3 = col0.z;
 double b3 = col1.z;
 double c3 = col2.z;
 double d3 = col3.z;
 double a4 = col0.w;
 double b4 = col1.w;
 double c4 = col2.w;
 double d4 = col3.w;
 col0.x  =   (b2 * (c3 * d4 - c4 * d3) - c2 * (b3 * d4 - b4 * d3) + d2 * (b3 * c4 - b4 * c3)) * scale_;
 col0.y  = - (a2 * (c3 * d4 - c4 * d3) - c2 * (a3 * d4 - a4 * d3) + d2 * (a3 * c4 - a4 * c3)) * scale_;
 col0.z  =   (a2 * (b3 * d4 - b4 * d3) - b2 * (a3 * d4 - a4 * d3) + d2 * (a3 * b4 - a4 * b3)) * scale_;
 col0.w  = - (a2 * (b3 * c4 - b4 * c3) - b2 * (a3 * c4 - a4 * c3) + c2 * (a3 * b4 - a4 * b3)) * scale_;
 col1.x  = - (b1 * (c3 * d4 - c4 * d3) - c1 * (b3 * d4 - b4 * d3) + d1 * (b3 * c4 - b4 * c3)) * scale_;
 col1.y  =   (a1 * (c3 * d4 - c4 * d3) - c1 * (a3 * d4 - a4 * d3) + d1 * (a3 * c4 - a4 * c3)) * scale_;
 col1.z  = - (a1 * (b3 * d4 - b4 * d3) - b1 * (a3 * d4 - a4 * d3) + d1 * (a3 * b4 - a4 * b3)) * scale_;
 col1.w  =   (a1 * (b3 * c4 - b4 * c3) - b1 * (a3 * c4 - a4 * c3) + c1 * (a3 * b4 - a4 * b3)) * scale_;
 col2.x  =   (b1 * (c2 * d4 - c4 * d2) - c1 * (b2 * d4 - b4 * d2) + d1 * (b2 * c4 - b4 * c2)) * scale_;
 col2.y  = - (a1 * (c2 * d4 - c4 * d2) - c1 * (a2 * d4 - a4 * d2) + d1 * (a2 * c4 - a4 * c2)) * scale_;
 col2.z  =   (a1 * (b2 * d4 - b4 * d2) - b1 * (a2 * d4 - a4 * d2) + d1 * (a2 * b4 - a4 * b2)) * scale_;
 col2.w  = - (a1 * (b2 * c4 - b4 * c2) - b1 * (a2 * c4 - a4 * c2) + c1 * (a2 * b4 - a4 * b2)) * scale_;
 col3.x  = - (b1 * (c2 * d3 - c3 * d2) - c1 * (b2 * d3 - b3 * d2) + d1 * (b2 * c3 - b3 * c2)) * scale_;
 col3.y  =   (a1 * (c2 * d3 - c3 * d2) - c1 * (a2 * d3 - a3 * d2) + d1 * (a2 * c3 - a3 * c2)) * scale_;
 col3.z  = - (a1 * (b2 * d3 - b3 * d2) - b1 * (a2 * d3 - a3 * d2) + d1 * (a2 * b3 - a3 * b2)) * scale_;
 col3.w  =   (a1 * (b2 * c3 - b3 * c2) - b1 * (a2 * c3 - a3 * c2) + c1 * (a2 * b3 - a3 * b2)) * scale_;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setColumn">
<button class="show-code">Code</button>
void <strong>setColumn</strong>(int column, <a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#setColumn"
              title="Permalink to mat4.setColumn">#</a></h4>
<div class="doc">
<p>Assigns the 
<span class="param">column</span> of the matrix 
<span class="param">arg</span></p>
<pre class="source">
void setColumn(int column, vec4 arg) {
 assert(column &gt;= 0 &amp;&amp; column &lt; 4);
 this[column] = arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setIdentity">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>setIdentity</strong>() <a class="anchor-link" href="#setIdentity"
              title="Permalink to mat4.setIdentity">#</a></h4>
<div class="doc">
<p>Makes <code>this</code> into the identity matrix.</p>
<pre class="source">
mat4 setIdentity() {
 col0.x = 1.0;
 col0.y = 0.0;
 col0.z = 0.0;
 col0.w = 0.0;
 col1.x = 0.0;
 col1.y = 1.0;
 col1.z = 0.0;
 col1.w = 0.0;
 col2.x = 0.0;
 col2.y = 0.0;
 col2.z = 1.0;
 col2.w = 0.0;
 col3.x = 0.0;
 col3.y = 0.0;
 col3.z = 0.0;
 col3.w = 1.0;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setRotation">
<button class="show-code">Code</button>
void <strong>setRotation</strong>(<a href="../vector_math/mat3.html">mat3</a> rotation) <a class="anchor-link" href="#setRotation"
              title="Permalink to mat4.setRotation">#</a></h4>
<div class="doc">
<p>Sets the rotation matrix in this homogeneous transformation matrix.</p>
<pre class="source">
void setRotation(mat3 rotation) {
 this.col0.xyz = rotation.col0;
 this.col1.xyz = rotation.col1;
 this.col2.xyz = rotation.col2;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setRotationX">
<button class="show-code">Code</button>
void <strong>setRotationX</strong>(num radians) <a class="anchor-link" href="#setRotationX"
              title="Permalink to mat4.setRotationX">#</a></h4>
<div class="doc">
<p>Sets the upper 3x3 to a rotation of 
<span class="param">radians</span> around X</p>
<pre class="source">
void setRotationX(num radians) {
 double radians_ = radians.toDouble();
 double c = Math.cos(radians_);
 double s = Math.sin(radians_);
 col0.x = 1.0;
 col0.y = 0.0;
 col0.z = 0.0;
 col1.x = 0.0;
 col1.y = c;
 col1.z = s;
 col2.x = 0.0;
 col2.y = -s;
 col2.z = c;
 col0.w = 0.0;
 col1.w = 0.0;
 col2.w = 0.0;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setRotationY">
<button class="show-code">Code</button>
void <strong>setRotationY</strong>(num radians) <a class="anchor-link" href="#setRotationY"
              title="Permalink to mat4.setRotationY">#</a></h4>
<div class="doc">
<p>Sets the upper 3x3 to a rotation of 
<span class="param">radians</span> around Y</p>
<pre class="source">
void setRotationY(num radians) {
 double radians_ = radians.toDouble();
 double c = Math.cos(radians_);
 double s = Math.sin(radians_);
 col0.x = c;
 col0.y = 0.0;
 col0.z = s;
 col1.x = 0.0;
 col1.y = 1.0;
 col1.z = 0.0;
 col2.x = -s;
 col2.y = 0.0;
 col2.z = c;
 col0.w = 0.0;
 col1.w = 0.0;
 col2.w = 0.0;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setRotationZ">
<button class="show-code">Code</button>
void <strong>setRotationZ</strong>(num radians) <a class="anchor-link" href="#setRotationZ"
              title="Permalink to mat4.setRotationZ">#</a></h4>
<div class="doc">
<p>Sets the upper 3x3 to a rotation of 
<span class="param">radians</span> around Z</p>
<pre class="source">
void setRotationZ(num radians) {
 double radians_ = radians.toDouble();
 double c = Math.cos(radians_);
 double s = Math.sin(radians_);
 col0.x = c;
 col0.y = s;
 col0.z = 0.0;
 col1.x = -s;
 col1.y = c;
 col1.z = 0.0;
 col2.x = 0.0;
 col2.y = 0.0;
 col2.z = 1.0;
 col0.w = 0.0;
 col1.w = 0.0;
 col2.w = 0.0;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setRow">
<button class="show-code">Code</button>
void <strong>setRow</strong>(int row, <a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#setRow"
              title="Permalink to mat4.setRow">#</a></h4>
<div class="doc">
<p>Assigns the <code>column</code> of the matrix 
<span class="param">arg</span></p>
<pre class="source">
void setRow(int row, vec4 arg) {
 assert(row &gt;= 0 &amp;&amp; row &lt; 4);
 col0[row] = arg.x;
 col1[row] = arg.y;
 col2[row] = arg.z;
 col3[row] = arg.w;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setTranslation">
<button class="show-code">Code</button>
void <strong>setTranslation</strong>(<a href="../vector_math/vec3.html">vec3</a> T) <a class="anchor-link" href="#setTranslation"
              title="Permalink to mat4.setTranslation">#</a></h4>
<div class="doc">
<p>Sets the translation vector in this homogeneous transformation matrix.</p>
<pre class="source">
void setTranslation(vec3 T) {
 col3.xyz = T;
}
</pre>
</div>
</div>
<div class="method"><h4 id="setZero">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>setZero</strong>() <a class="anchor-link" href="#setZero"
              title="Permalink to mat4.setZero">#</a></h4>
<div class="doc">
<p>Zeros <code>this</code>.</p>
<pre class="source">
mat4 setZero() {
 col0.x = 0.0;
 col0.y = 0.0;
 col0.z = 0.0;
 col0.w = 0.0;
 col1.x = 0.0;
 col1.y = 0.0;
 col1.z = 0.0;
 col1.w = 0.0;
 col2.x = 0.0;
 col2.y = 0.0;
 col2.z = 0.0;
 col2.w = 0.0;
 col3.x = 0.0;
 col3.y = 0.0;
 col3.z = 0.0;
 col3.w = 0.0;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="sub">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>sub</strong>(<a href="../vector_math/mat4.html">mat4</a> o) <a class="anchor-link" href="#sub"
              title="Permalink to mat4.sub">#</a></h4>
<div class="doc">
<pre class="source">
mat4 sub(mat4 o) {
 col0.x = col0.x - o.col0.x;
 col0.y = col0.y - o.col0.y;
 col0.z = col0.z - o.col0.z;
 col0.w = col0.w - o.col0.w;
 col1.x = col1.x - o.col1.x;
 col1.y = col1.y - o.col1.y;
 col1.z = col1.z - o.col1.z;
 col1.w = col1.w - o.col1.w;
 col2.x = col2.x - o.col2.x;
 col2.y = col2.y - o.col2.y;
 col2.z = col2.z - o.col2.z;
 col2.w = col2.w - o.col2.w;
 col3.x = col3.x - o.col3.x;
 col3.y = col3.y - o.col3.y;
 col3.z = col3.z - o.col3.z;
 col3.w = col3.w - o.col3.w;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="toString">
<button class="show-code">Code</button>
String <strong>toString</strong>() <a class="anchor-link" href="#toString"
              title="Permalink to mat4.toString">#</a></h4>
<div class="doc">
<p>Returns a printable string</p>
<pre class="source">
String toString() {
 String s = '';
 s = '$s[0] ${getRow(0)}\n';
 s = '$s[1] ${getRow(1)}\n';
 s = '$s[2] ${getRow(2)}\n';
 s = '$s[3] ${getRow(3)}\n';
 return s;
}
</pre>
</div>
</div>
<div class="method"><h4 id="trace">
<button class="show-code">Code</button>
double <strong>trace</strong>() <a class="anchor-link" href="#trace"
              title="Permalink to mat4.trace">#</a></h4>
<div class="doc">
<p>Returns the trace of the matrix. The trace of a matrix is the sum of the diagonal entries</p>
<pre class="source">
double trace() {
 double t = 0.0;
 t += col0.x;
 t += col1.y;
 t += col2.z;
 t += col3.w;
 return t;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transform">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>transform</strong>(<a href="../vector_math/vec4.html">vec4</a> arg) <a class="anchor-link" href="#transform"
              title="Permalink to mat4.transform">#</a></h4>
<div class="doc">
<pre class="source">
vec4 transform(vec4 arg) {
 double x_ =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + (this.col3.x * arg.w);
 double y_ =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + (this.col3.y * arg.w);
 double z_ =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + (this.col3.z * arg.w);
 double w_ =  (this.col0.w * arg.x) + (this.col1.w * arg.y) + (this.col2.w * arg.z) + (this.col3.w * arg.w);
 arg.x = x_;
 arg.y = y_;
 arg.z = z_;
 arg.w = w_;
 return arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transform3">
<button class="show-code">Code</button>
<a href="../vector_math/vec3.html">vec3</a> <strong>transform3</strong>(<a href="../vector_math/vec3.html">vec3</a> arg) <a class="anchor-link" href="#transform3"
              title="Permalink to mat4.transform3">#</a></h4>
<div class="doc">
<pre class="source">
vec3 transform3(vec3 arg) {
 double x_ =  (this.col0.x * arg.x) + (this.col1.x * arg.y) + (this.col2.x * arg.z) + col3.x;
 double y_ =  (this.col0.y * arg.x) + (this.col1.y * arg.y) + (this.col2.y * arg.z) + col3.y;
 double z_ =  (this.col0.z * arg.x) + (this.col1.z * arg.y) + (this.col2.z * arg.z) + col3.z;
 arg.x = x_;
 arg.y = y_;
 arg.z = z_;
 return arg;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transformed">
<button class="show-code">Code</button>
<a href="../vector_math/vec4.html">vec4</a> <strong>transformed</strong>(<a href="../vector_math/vec4.html">vec4</a> arg, [<a href="../vector_math/vec4.html">vec4</a> out = null]) <a class="anchor-link" href="#transformed"
              title="Permalink to mat4.transformed">#</a></h4>
<div class="doc">
<pre class="source">
vec4 transformed(vec4 arg, [vec4 out=null]) {
 if (out == null) {
   out = new vec4.copy(arg);
 } else {
   out.copyFrom(arg);
 }
 return transform(out);
}
</pre>
</div>
</div>
<div class="method"><h4 id="transformed3">
<button class="show-code">Code</button>
<a href="../vector_math/vec3.html">vec3</a> <strong>transformed3</strong>(<a href="../vector_math/vec3.html">vec3</a> arg, [<a href="../vector_math/vec3.html">vec3</a> out = null]) <a class="anchor-link" href="#transformed3"
              title="Permalink to mat4.transformed3">#</a></h4>
<div class="doc">
<pre class="source">
vec3 transformed3(vec3 arg, [vec3 out=null]) {
 if (out == null) {
   out = new vec3.copy(arg);
 } else {
   out.copyFrom(arg);
 }
 return transform3(out);
}
</pre>
</div>
</div>
<div class="method"><h4 id="translate">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>translate</strong>(x, [num y = 0.0, num z = 0.0]) <a class="anchor-link" href="#translate"
              title="Permalink to mat4.translate">#</a></h4>
<div class="doc">
<p>Translate this matrix by a <a class="crossref" href="../vector_math/vec3.html">vec3</a>, <a class="crossref" href="../vector_math/vec4.html">vec4</a>, or x,y,z</p>
<pre class="source">
mat4 translate(dynamic x, [num y = 0.0, num z = 0.0]) {
 double tx;
 double ty;
 double tz;
 double tw = x is vec4 ? x.w : 1.0;
 if (x is vec3 || x is vec4) {
   tx = x.x;
   ty = x.y;
   tz = x.z;
 } else {
   tx = x;
   ty = y;
   tz = z;
 }
 var t1 = col0.x * tx + col1.x * ty + col2.x * tz + col3.x * tw;
 var t2 = col0.y * tx + col1.y * ty + col2.y * tz + col3.y * tw;
 var t3 = col0.z * tx + col1.z * ty + col2.z * tz + col3.z * tw;
 var t4 = col0.w * tx + col1.w * ty + col2.w * tz + col3.w * tw;
 col3.x = t1;
 col3.y = t2;
 col3.z = t3;
 col3.w = t4;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transpose">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>transpose</strong>() <a class="anchor-link" href="#transpose"
              title="Permalink to mat4.transpose">#</a></h4>
<div class="doc">
<pre class="source">
mat4 transpose() {
 double temp;
 temp = col1.x;
 col1.x = col0.y;
 col0.y = temp;
 temp = col2.x;
 col2.x = col0.z;
 col0.z = temp;
 temp = col3.x;
 col3.x = col0.w;
 col0.w = temp;
 temp = col2.y;
 col2.y = col1.z;
 col1.z = temp;
 temp = col3.y;
 col3.y = col1.w;
 col1.w = temp;
 temp = col3.z;
 col3.z = col2.w;
 col2.w = temp;
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transposed">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>transposed</strong>() <a class="anchor-link" href="#transposed"
              title="Permalink to mat4.transposed">#</a></h4>
<div class="doc">
<p>Returns the tranpose of this.</p>
<pre class="source">
mat4 transposed() {
 mat4 r = new mat4.zero();
 r.col0.x = col0.x;
 r.col0.y = col1.x;
 r.col0.z = col2.x;
 r.col0.w = col3.x;
 r.col1.x = col0.y;
 r.col1.y = col1.y;
 r.col1.z = col2.y;
 r.col1.w = col3.y;
 r.col2.x = col0.z;
 r.col2.y = col1.z;
 r.col2.z = col2.z;
 r.col2.w = col3.z;
 r.col3.x = col0.w;
 r.col3.y = col1.w;
 r.col3.z = col2.w;
 r.col3.w = col3.w;
 return r;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transposeMultiply">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>transposeMultiply</strong>(<a href="../vector_math/mat4.html">mat4</a> arg) <a class="anchor-link" href="#transposeMultiply"
              title="Permalink to mat4.transposeMultiply">#</a></h4>
<div class="doc">
<pre class="source">
mat4 transposeMultiply(mat4 arg) {
 double m00 = col0.x;
 double m01 = col0.y;
 double m02 = col0.z;
 double m03 = col0.w;
 double m10 = col1.x;
 double m11 = col1.y;
 double m12 = col1.z;
 double m13 = col1.w;
 double m20 = col2.x;
 double m21 = col2.y;
 double m22 = col2.z;
 double m23 = col2.w;
 double m30 = col3.x;
 double m31 = col3.y;
 double m32 = col3.z;
 double m33 = col3.w;
 col0.x =  (m00 * arg.col0.x) + (m01 * arg.col0.y) + (m02 * arg.col0.z) + (m03 * arg.col0.w);
 col1.x =  (m00 * arg.col1.x) + (m01 * arg.col1.y) + (m02 * arg.col1.z) + (m03 * arg.col1.w);
 col2.x =  (m00 * arg.col2.x) + (m01 * arg.col2.y) + (m02 * arg.col2.z) + (m03 * arg.col2.w);
 col3.x =  (m00 * arg.col3.x) + (m01 * arg.col3.y) + (m02 * arg.col3.z) + (m03 * arg.col3.w);
 col0.y =  (m10 * arg.col0.x) + (m11 * arg.col0.y) + (m12 * arg.col0.z) + (m13 * arg.col0.w);
 col1.y =  (m10 * arg.col1.x) + (m11 * arg.col1.y) + (m12 * arg.col1.z) + (m13 * arg.col1.w);
 col2.y =  (m10 * arg.col2.x) + (m11 * arg.col2.y) + (m12 * arg.col2.z) + (m13 * arg.col2.w);
 col3.y =  (m10 * arg.col3.x) + (m11 * arg.col3.y) + (m12 * arg.col3.z) + (m13 * arg.col3.w);
 col0.z =  (m20 * arg.col0.x) + (m21 * arg.col0.y) + (m22 * arg.col0.z) + (m23 * arg.col0.w);
 col1.z =  (m20 * arg.col1.x) + (m21 * arg.col1.y) + (m22 * arg.col1.z) + (m23 * arg.col1.w);
 col2.z =  (m20 * arg.col2.x) + (m21 * arg.col2.y) + (m22 * arg.col2.z) + (m23 * arg.col2.w);
 col3.z =  (m20 * arg.col3.x) + (m21 * arg.col3.y) + (m22 * arg.col3.z) + (m23 * arg.col3.w);
 col0.w =  (m30 * arg.col0.x) + (m31 * arg.col0.y) + (m32 * arg.col0.z) + (m33 * arg.col0.w);
 col1.w =  (m30 * arg.col1.x) + (m31 * arg.col1.y) + (m32 * arg.col1.z) + (m33 * arg.col1.w);
 col2.w =  (m30 * arg.col2.x) + (m31 * arg.col2.y) + (m32 * arg.col2.z) + (m33 * arg.col2.w);
 col3.w =  (m30 * arg.col3.x) + (m31 * arg.col3.y) + (m32 * arg.col3.z) + (m33 * arg.col3.w);
 return this;
}
</pre>
</div>
</div>
<div class="method"><h4 id="transposeRotation">
<button class="show-code">Code</button>
<a href="../vector_math/mat4.html">mat4</a> <strong>transposeRotation</strong>() <a class="anchor-link" href="#transposeRotation"
              title="Permalink to mat4.transposeRotation">#</a></h4>
<div class="doc">
<p>Transposes just the upper 3x3 rotation matrix.</p>
<pre class="source">
mat4 transposeRotation() {
 double temp;
 temp = this.col0.y;
 this.col0.y = this.col1.x;
 this.col1.x = temp;
 temp = this.col0.z;
 this.col0.z = this.col2.x;
 this.col2.x = temp;
 temp = this.col1.x;
 this.col1.x = this.col0.y;
 this.col0.y = temp;
 temp = this.col1.z;
 this.col1.z = this.col2.y;
 this.col2.y = temp;
 temp = this.col2.x;
 this.col2.x = this.col0.z;
 this.col0.z = temp;
 temp = this.col2.y;
 this.col2.y = this.col1.z;
 this.col1.z = temp;
 return this;
}
</pre>
</div>
</div>
</div>
        </div>
        <div class="clear"></div>
        </div>
        <div class="footer">
          
        </div>
        <script async src="../client-live-nav.js"></script>
        </body></html>
        
